18

I just spent 20 minutes changing a custom object's default record type for every profile that we have. For future reference, is there a way to change this across all profiles?

  • This is worth to suggest on ideas site – Saariko Oct 11 '12 at 15:19
13

Not in one shot. The best I think you can do this via the Force.com Migration Tool and the metadata API. You would need to perform the following steps:

  1. Download all of the profiles. This is easy since the wildcard operator works with Profiles.
  2. Open each file (they're XML), find the entry, and update it. It will look like this:

    <recordTypeVisibilities>
    <default>true</default>
    <recordTypes>MyObject.NewDefaultType</recordTypes>
    <visible>true</visibles>
    </recordTypeVisibilitiess>

  3. Upload the new metadata

Assuming you can do a global find and replace I think this would be easier than clicking through the web UI.

Caveat: This may only work on custom objects; the Metadata API does not work completely with standard fields on standard objects. Since you mentioned custom object it would probably work fine.

| improve this answer | |
  • This is great information. I haven't explored the migration tool yet but this gives me a great project to begin with. Thanks. – dannymorty Oct 11 '12 at 15:19
  • Way to go mike!!!impressed – Mohith Shrivastava Oct 11 '12 at 15:28
  • 3
    Since I'm here, I may as well add that you can create a new record type (setting it as default), then deleting the old record type (and replacing with the new type). This has the same effect and only needs the UI, no code required. – sfdcfox Sep 26 '13 at 15:52
  • 2
    @MikeChale I missed this comment. When you delete an RT, you can replace it with another; so just replace the old with the new, and you're done. – sfdcfox Jan 31 '14 at 14:40
  • 3
    I found this DOES work for standard objects too. The trick is that you also need to include the standard object as part of your package.xml that you use when retrieving the profiles. For example, if you want to modify Campaign record type visibility, you muse also retrieve the Campaign object metadata along with the profiles that you want to change. This will cause the Campaign recordTypeVisibilities for the Campaign record types to be include in the Profile meta xml files. – tlfu Nov 18 '16 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.