4

We have inherited some code from another development team, and the code (triggers especially) requires custom settings to execute.

We have put the code into a continuous integration process, using CodeShip and CumulusCI.

What my question is, how can I automate the creation of custom settings from my developer org (package) through to feature, master, packaging, beta and release orgs? Is this something that is possible?

2

If it's practicable for you, you might want to consider migrating your custom settings to custom metadata types. Records of custom metadata types can be deployed/migrated with standard Salesforce ALM tools like changesets or the Force.com Migration tool.

1

Assuming you are talking about the data (the rows) rather than the structure (that is already handled by e.g. the sf:deploy Ant task), I suggest you write a small Ant task that wraps the REST API and can read and write the custom setting objects. We have done that for a slightly different purpose and it is only about 500 lines of code. Having the data in JSON format makes it easy for people to look at the settings data.

1

Since you're using CumulusCI already, your build environment already has Python and the simple-salesforce module set up. You could use simple-salesforce to write the custom settings into the org.

The run_apex_tests.py script in CumulusCI is an example of using simple-salesforce to query the Tooling API which would be similar to interact with data like custom settings.

CumulusCI's build.xml has an example of how that python script can be called from Ant (NOTE: This would require setting up a python environment on each developer's machine):

I think this is a pretty common challenge which seems like it would be great to include in CumulusCI. There are many use cases that could be solved by being able to easily automate the installation of managed packages, deployment of metadata, and CRUD around data and custom settings. It's been a dream of mine for a while and I'd love to work with someone in the community to help create that functionality. Just create an issue in the CumulusCI Github repository.

For a totally different solution to your challenge, there's a reason this doesn't exist yet in CumulusCI. The Nonprofit Starter Pack 3 (aka Cumulus) uses a facade to handle setting default values in custom settings which has proved very useful both for development and build but also for end users. You can check out the source code of the UTIL_CustomSettingsFacade.cls for more info.

0

Are you using Force.com Migration Tool for deploying and retrieving? If so, you can deal with Custom Settings similarly to Custom Object.

ref. https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/customobject.htm?search_text=custom%20setting

when you add customSettingsType and customSettingsVisibility properties, it's recognized as Custom Settings.

  • 1
    I assume that Connor wants to get the values of the custom settings (the SObject rows) replicated not just the structure. Are you talking about only the structure? – Keith C Jul 16 '15 at 9:49

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.