1

I am wondering if there is a way to automate the process of reconfiguring a Salesforce sandbox to a specific configuration, post-refresh. Currently I have read about a python add-on to create a script in order to automate the process. I have also heard there are ways through SOQL to automate a post-refresh.

I am just wondering if there is a better way to go about writing a script to refresh a sandbox in order to reconfigure to a default by just 'clicking a button'.

Thanks!

EDIT:

The type of things I would like to automate is everything from running other specific scripts, creating/reassigning org-wide email addresses, editing custom labels, and more.

I am relatively new to Apex and I am still learning about it's advantages and limitations. If these are all in the wheelhouse of Apex then I think that is my best bet, but I am just curious of other options that are out there in case some of the configuration requires scripting outside of Apex.

  • What is it you are hoping to automate? Can you please edit this question to be more specific? Depending on what you hope to accomplish, you may want to look into the SandboxPostCopy interface. – Adrian Larson Sep 12 '18 at 22:29
  • just edited. Hope that provides more context. Thanks! – J1593 Sep 12 '18 at 22:36
0

When you create a new Sandbox the final step is to [optionally] select an Apex Class to run in the Sandbox post-copy.

Anything you can affect in your configuration through Apex you can script in this manner (e.g. create test records, set user logins, etc).

EDIT:

I apologize in advance for whatever opinion follows, but these are my opinions from my experience.

Targeting the edit of the question - I would recommend researching the other configs you want to change and how to manipulate them with Apex. If any of your updates can be handled in Apex I recommend that solution as it is the most robust. That being said, the items you reference are not available in Apex (yet?) so you'll need to get...creative.

Theoretically you could write one or several Selenium scripts to get the job done. Selenium is a web browser automation tool most often used for automating front-end testing of web applications. Courtesy of Salesforce' consistent design of their classic admin interface you could write Selenium scripts that would last for some time. (I've shied away from the LEX Admin Interface so I cannot state with any certainty whether the design changes or not or with what frequency or significance.)

However, I would not recommend this solution unless you're an extreme Sandbox user. Most orgs I've encountered will update their ongoing Sandboxes (of which they typically have 2-3) on an approximately monthly cadence with post-refresh work taking an hour or two at most. When working on a team I've always maintained an Refresh Update Log that lists the manual steps one needs to take post-refresh and added to it with each new Sandbox. ("Oh yeah, I forgot we changed ABC in prod last week. Adding to the Refresh Update Log.") If you maintain diligent change logs for production you can quite easily scan through your month of updates and add necessary steps to your Refresh Update Log.

If you choose to go with Selenium you'll face a potentially significant upfront investment (especially if you have to learn how to use it first or hire an Automation Contractor) with ongoing maintenance. Depending on your situation, it may be worth the time but I doubt it - conceptually I'm thinking you'd need to be performing daily refreshes or refreshes on dozens of Sandboxes to warrant this cost. If that is the case it might make more sense to use your Sandboxes almost like git branches - where you merge small changes from various "user story boxes" into a "feature box" into a "staging box" and finally into production. Then you'd only need to consistently refresh your staging and/or feature Sandboxes since U.S. Sandbox changes would be very targeted.

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.