I am trying to selectively update the record type visibility of a particular record type for a particular profile.

Would the updateMetadata api be able to do this? https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_updateMetadata.htm

1 Answer 1


Yes, updateMetadata would work here. Salesforce only updates explicitly mentioned elements, so if your Profile object only had the single record type visibility, only that permission would be changed.

We designed Profile metadata deployment to overlay the existing Profile settings in a target org. For example, if you disable permissions for a profile, the newly disabled permission information isn't exported. To force all Profile changes to deploy through metadata, including permission disablement, add code that explicitly indicates disabled permissions. For example, add this code to the Profile metadata .xml file before deploying into a target org: <value>false</value>. --Documentation

  • Thanks. The following code worked ``` Profile pf = new Profile(); pf.setFullName("Finance"); ProfileRecordTypeVisibility prv = new ProfileRecordTypeVisibility(); prv.setRecordType("Opportunity.RecordType_API_Name"); prv.setDefault(false); prv.setVisible(true); pf.setRecordTypeVisibilities(new ProfileRecordTypeVisibility[] {prv}); SaveResult[] results = metadataConnection .updateMetadata(new Metadata[] { pf }); ``` Commented Apr 23 at 12:59
  • Is there a way to selectively update PermissionSetRecordTypeVisibility also? I tried the same with PermissionSet but the other permissions on the PermissionSet got wiped out. Is there a parameter i can use to keep the existing permissions and only add the new permissions selectively? Commented Apr 23 at 13:00
  • 1
    @jacksparrow007 No, permission sets are always all-or-none. This makes them more reliable when deploying from a "source of truth," the new DX development model. You'd have to get the entire permission set first, then find and change the appropriate value.
    – sfdcfox
    Commented Apr 23 at 13:02

You must log in to answer this question.

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