如何获取顶点页面中使用的所有自定义标签信息?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何获取顶点页面中使用的所有自定义标签信息?相关的知识,希望对你有一定的参考价值。
我想通过rest API获取所有自定义标签。我在顶点页面中使用了自定义标签
{!$ Label.MyCustomLabel}
。所以我可以通过rest api获取有关MyCustomLabel的信息。
任何指导将不胜感激。谢谢
答案
从组织中获取自定义标签并不是一种简单的方法。 CustomLabel / ExternalString对象不可查询,其余api的services/data/v43.0/nouns
部分也不包含它们。
现在从Salesforce获取自定义标签的唯一方法是阅读元数据。最快的方法可能是使用同步listMetadata
和readMetadata
调用。这使用SOAP api,因此这里涉及一些XML。
1.,listMetadata
,用您的组织ID替换org-id
,并用您的会话ID替换session-id
。
curl
-H 'Content-Type: text/xml'
-H 'SOAPAction: ""'
https://ap4.salesforce.com/services/Soap/m/38.0/org-id
-d '<?xml version="1.0" encoding="utf-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header><n1:SessionHeader xmlns:n1="http://soap.sforce.com/2006/04/metadata"><n1:sessionId>session-id</n1:sessionId></n1:SessionHeader></env:Header><env:Body><n1:listMetadata xmlns:n1="http://soap.sforce.com/2006/04/metadata"><n1:queries><n1:type type="xsd:string">CustomLabel</n1:type></n1:queries></n1:listMetadata></env:Body></env:Envelope>'
2.,拉出<fullName>
标签内的所有自定义标签名称
3.,readMetadata
,将org-id
替换为您的组织ID,将session-id
替换为您的会话ID,并将custom-label-name
替换为自定义标签的名称。
curl
-H 'Content-Type: text/xml'
-H 'SOAPAction: ""'
https://ap4.salesforce.com/services/Soap/m/38.0/org-id
-d '<?xml version="1.0" encoding="utf-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header><n1:SessionHeader xmlns:n1="http://soap.sforce.com/2006/04/metadata"><n1:sessionId>session-id</n1:sessionId></n1:SessionHeader></env:Header><env:Body><n1:readMetadata xmlns:n1="http://soap.sforce.com/2006/04/metadata"><n1:type type="xsd:string">CustomLabel</n1:type><n1:fullNames type="xsd:string">custom-label-name</n1:fullNames><n1:fullNames type="xsd:string">custom-label-name</n1:fullNames></n1:readMetadata></env:Body></env:Envelope>'
以上是关于如何获取顶点页面中使用的所有自定义标签信息?的主要内容,如果未能解决你的问题,请参考以下文章
Django admin - 如何获取模板标签中的所有注册模型?
如何在 Gatsby 中获取所有 Wordpress 帖子和显示标签