While talking with salesforce administrators, I often get the request to be able to clone a user. It's a common user provisioning flow in IT. As an administrator, it's easier to ask who a new user is most like rather than figure out all the settings and apps they need to get up and running in the organization as quickly as possible. There are even a couple of ideas on the ideaexchange and answers forum about it.
Cloning a user has three simple requirements:
- I should be able to provision a new user by creating a copy of an existing one.
- I should only have to provide the minimal information necessary for the clone to take place.
- The new user should include the right level of access (public groups and permission sets) and apps necessary to get them up and running as soon as possible.
The first requirement is pretty easy. I just need to easily search for an existing user to set as my source user.
It turns out I only need three user fields to create a unique clone or target user for the second requirement: first name, last name, and email address. Everything else can either be assumed based on that information or copied directly from the source user.
The third requirement is the tough one. Cloning a parent object is pretty easy. There are lots of articles and hacks like Salesforce: Clone Records Using a Custom Button or Link or Clone a User In Salesforce.com Without Apex. However the user object is unique and there are a number of additional hurdles to overcome when cloning.
Last summer I pitched the idea to bring a summer intern on board to build a sample Apex app that could simplify some of the clone user flow. Ian Dalton came on board and built out the majority of Apex we needed to demonstrate that it was possible. I built out the rest to surface it as a force.com app with a simple interface.
The flow is pretty simple:
- search for a source user.
- enter the minimal information for the target user.
- click the clone button.
- click the newly created target user's link and view their record. You'll find the permission sets and public groups came over as well.
To try this out, download the sample code from my github repository.
The easiest way to install this project into your org is to make use of the workbench tool (http://workbench.developerforce.com).
- Download a ZIP of the repository.
- Open Workbench.
- Login to the desired organization with a user that has Modify All Data permission.
- Select Deploy from the migration menu and when prompted, choose your zip file and select 'Allow Missing Files' checkbox before deploying it.
- If you get an error that the deployment failed because package.xml cannot be found: unzip the cloneUser.zip file you downloaded and use the terminal to re-zip it (e.g. zip -r cloneUser.zip cloneUser) before retrying step 4.
Once the permission set is assigned, you should be able to select the app from the app picker and begin cloning. All that is required is a source user, a first name, last name, and an email address.
Building administrative apps like the ability to clone users easily is a great way to learn more about the salesforce platform and build value within your organization at the same time.
Title is from a poem 'On Cloning' by M M Marshall
Picture is from Deviantart by dandroid
This is a really great app. I installed it in one of our sandboxes and it works perfectly. The only issue I found is that one of my delegated admins was able to clone a user who has a role and profile not assigned to that delegated admin. Is there a setting I need to toggle to make sure that doesn't happen?
Other than that, it's really great, and I think we can make use of it if we can work around the above issue.
Hi Nate, Thanks for trying out the app! Delegated Administration doesn't follow the same access check as this app which relies just on whether you have access to the underlying apex class. If you assign the permission set, it grants access to clone *any* user, not just the ones that are part of the role hierarchy you're responsible for. Hope it works out for your other use cases! Thanks!Delete