3

Rather new to Salesforce here, trying to set up some automated object and field creation through the SOAP API. Making a new custom object is no problem, making a new custom field is no problem, and I've discovered how to add a custom field to a layout.

However, every custom field I make through the API has visibility off for every profile. I was under the impression after doing some research that adding a field to the page layout allowed the API to view that field, but that doesn't seem to be the case. Even when a field is added to the layout, it doesn't appear when the object is described.

Is there any way to create a custom field through the SOAP API without having to manually set the visibility in the UI?

1
  • 1
    The UI respects Field Level Security which amounts to field by field settings in profiles (and permission sets). So one solution is to look for an API that lets you modify these settings for the profile your users run under so in total you add the field to the object, the layout and the profile.
    – Keith C
    Jun 6, 2014 at 22:55

2 Answers 2

1

@keith-c is right that the layouts work in combination with the field security set in the profile. The use case for that is two users with different profiles who share the same layout. One profile can access Field A while the other profile cannot. In this case, you don't have to build two different layouts.

If you're wanting to do this exclusively through the Metadata API, you'd need to also deploy modified versions of all your profiles which include the new field's visibility settings.

Here's an example of the elements you'd need in the profile:

<fieldPermissions>
    <editable>true</editable>
    <field>Contact.Gender__c</field>
    <readable>true</readable>
</fieldPermissions>

Note that it's probably a good idea to retrieve the profiles first before editing them. If you are working with an older copy of the profile on disk you might wind up deploying the older version and overwriting other changes made to the profile.

Here's the relevant Metadata API docs: http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_profile.htm#profilefieldlevelsecurity_title

0

You can use the Metadata API to set the FLS of the fields which are not visible.

1
  • Some examples or web links? Jun 11, 2014 at 12:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .