Is there a way to soql procesbuilder to tun activation off?

For example

List<Processbuilder> pbColl = new List<Processbuilder>();  
Processbuilder pb=[SELECT status FROM Processbuilder WHERE status Active];

for(Processbuilder turnoff : pb){
            turnoff.status = false;
update pbColl;

If not is there a simple way to turn all activated Processes off/on?


If you want to be able to "flip a switch" in code to disable Process Builders, you could use a boolean Custom Setting field. Then update your Process Builders so that the very first entry criterion is the custom setting being true, and if it is not, stop. Then from Apex you will be able to set the Custom Setting field to false whenever you need to stop the processes from executing.


Not natively in Apex. You'd need to use the Tooling API and query InteractionDefinitionVersion. See also: Error - Failed To Execute Flow - 301 Prefix - Process Builder That would allow you to query for the data, but I don't think you'd be able to turn the flows on/off this way. You may be having a bit of an X-Y Problem. You will generally get better answers if you describe your high level objective rather than the specific means you are pursuing to achieve it.


Ben Edwards has a set of tools which includes one called Salesforce Switch which enabled you to do this.

He has also put the source code on GitHub:

I also wrote a lightning component to allow on mass enable/disable:

At it's core, it uses the Tooling API.

Getting Flow/Process Info

GET: /services/data/v43.0/tooling/query?q=Select+Id,ActiveVersion.VersionNumber,LatestVersion.VersionNumber,DeveloperName+From+FlowDefinition+ORDER+BY+DeveloperName

Updating Flow/Process Info

POST: /services/data/v43.0/tooling/sobjects/FlowDefinition/{FlowId}/?_HttpMethod=PATCH

With JSON:

  'Metadata': {
       'activeVersionNumber': {versionNumber/null}

NOTE: the ?_HttpMethod=PATCH is only required if your calling from Apex

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.