Reputation: 91
I am trying to create a custom field on the Leads object using the metadata api. More specifically using the jsforce node module.
I can create the field just fine, but I can't query it after it's created. I have searched for a way to set field level permissions on the field using the API but I haven't found anything.
Is there a way to set field level security on a newly created custom field? Or do I have to go into the Salesforce UI to do it?
This post says that I probably need to do it from the UI.
https://developer.salesforce.com/forums/?id=9060G000000UVldQAG
But if thats the case, what good is the API then?
Upvotes: 0
Views: 2244
Reputation: 2817
You can make the field level security using the metadata API. When you create a field, send the field level permission in Admin Profile type metadata.
For example,
<?xml version="1.0" encoding="UTF-8"?>
<Profile xmlns="http://soap.sforce.com/2006/04/metadata">
<fieldPermissions>
<editable>true</editable>
<field>ObjectName__c.Field__c</field>
<readable>true</readable>
</fieldPermissions>
</Profile>
Upvotes: 0