2

How can I clone a salesforce Profile? I'd prefer to use Apex or DX/CLI. Our normal process for setting up an Org is to clone standard profiles, and then customize those clones.

This probably happens dozens of times a month, so I'd like to be able to script or automate it.

1

1 Answer 1

0

There are a couple of ways you can pragmatically create profiles, I would recommend looking at the potential to use the SOAP api or MetadataAPI with the SOAP API there is a create() callout which could fit the purpose.

Within the Metadata API you have clone() action override which could potentially be leverage to fit the purpose

https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm

e.g. to call a clone from apex where clone(preserveId, isDeepClone, preserveReadonlyTimestamps, preserveAutonumber)

Account a = new Account(Name=myAccount);
insert a;
Account aClone = a.clone(false,false,false,false);
insert aClone;
3
  • Can you give more detail or an example of how to call the clone() method via Apex or DX/CLI?
    – SeanW
    Commented Aug 14, 2018 at 13:08
  • @SeanW See above I have added a basic example for you
    – Nebbyyy
    Commented Aug 15, 2018 at 15:14
  • I think that Accounts behave differently from Profiles.
    – SeanW
    Commented Aug 15, 2018 at 17:50

You must log in to answer this question.

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