Обновите fieldPermissions с помощью API метаданных Salesforce
Я пытаюсь обновить разрешения для поля, созданного из API, чтобы оно было видимым и использованным.
поэтому я делаю это через API метаданных salesforce.
responses = client.call(:update_metadata, message_tag: :updateMetadata, message: {metadata: { fullName: 'Admin', fieldPermissions: {field: "Contact.custom_attribute1_soap__c", editable: true, readable: true}}, :attributes! => {metadata: {"xsi:type" => "Profile"}}})
client
это экземпляр жемчужины Савона.
что дает мне это, и мне кажется правильным!
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://soap.sforce.com/2006/04/metadata" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header>
<tns:SessionHeader>
<tns:sessionId>s3ss10n1d</tns:sessionId>
</tns:SessionHeader>
</env:Header>
<env:Body>
<tns:updateMetadata>
<tns:metadata xsi:type="Profile">
<tns:fullName>Admin</tns:fullName>
<tns:fieldPermissions>
<tns:field>Contact.custom_attribute1_soap__c</tns:field>
<tns:editable>true</tns:editable>
<tns:readable>true</tns:readable>
</tns:fieldPermissions>
</tns:metadata>
</tns:updateMetadata>
</env:Body>
</env:Envelope>
Однако Salesforce отправляет мне обратно ошибку. После нескольких часов поиска документации я не понимаю.
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Client</faultcode>
<faultstring>Unable to determine type mapping for type Profile. Type is illegal here.</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
Один из вас мог бы объяснить мне мою ошибку или дать мне способ изменить разрешения для настраиваемого поля, созданного через API, пожалуйста?
0 ответов
Вы пропустили атрибут "xmlns": "http://soap.sforce.com/2006/04/metadata"
Пытаться:
responses = client.call(
:update_metadata,
message_tag: :updateMetadata,
message: {
metadata: {fullName: 'Admin', fieldPermissions: {field: "Contact.custom_attribute1_soap__c", editable: true, readable: true}},
:attributes! => {metadata: {"xsi:type" => "Profile", "xmlns": "http://soap.sforce.com/2006/04/metadata"}}
})
В моем случае работала следующая схема:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tns="http://soap.sforce.com/2006/04/metadata">
<soapenv:Header>
<tns:SessionHeader>
<tns:sessionId>your_id</tns:sessionId>
</tns:SessionHeader>
</soapenv:Header>
<soapenv:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<tns:updateMetadata>
<tns:metadata xsi:type="tns:Profile">
<tns:fullName>Admin</tns:fullName>
<tns:fieldPermissions>
<tns:field>CustomObject__c.CustomField__c</tns:field>
<tns:editable>true</tns:editable>
<tns:readable>true</tns:readable>
</tns:fieldPermissions>
</tns:metadata>
</tns:updateMetadata>
</soapenv:Body>
</soapenv:Envelope>