We are using the Metadata API to add Custom Fields to the Account object in Salesforce. We are able to create the custom fields, but then the Salesforce user has to manually login to their account and set the Field-Level Security to "Visible" for each Custom Field. Is there a way to set the visibility of the field or to set the permissions for the fields we add via the Metadata or Soap API's when we add the fields?
If you have an existing PermissionSet you can use an associated FieldPermissions to grant Read permissions. This can be done via the Partner API.
Fieldto 'Account.CustomField__c' (where CustomField__c is the API name of your field)
ParentIdto the ID of the existing PermissionSet,
You can use the Profile object in the metadata API to deploy object and field level permissions for the new object/fields. Read the documentation for more details.
We answered the question (with suggestions from sfdcfox in this thread and blogs by Terry Luschen). We provided a detailed description of our answer at the Salesforce Developer Forum.
We still have some outstanding issues regarding support for Dynamic Custom Fields for users with Salesforce Profession Edition and on record limits when using the SOAP API to transfer data. Any guidance on those topics is welcome.