0

I have a managed package which ships with a template process builder which is inactive. I am trying to find a way to activate this process builder via the metadata API. Activating it via the UI is simple, just going to the process builder and clicking "Activate".

To activate an unmanaged process builder, I can simply retrieve it, change the status field and deploy:

sfdx force:source:retrieve -m Flow:MyProcessBuilder

replace <status>Draft</status> with <status>Active</status> in the flow

sfdx force:source:deploy -m Flow:MyProcessBuilder

This results in the process builder being activated.

If I do the same thing with my managed process, this results in the error message:

c:\>sfdx force:source:deploy -m Flow:namespace__PackagedProcessBuilder
PROJECT PATH                                                   ERROR
─────────────────────────────────────────────────────────────  ────────────────────────────
force-app\main\default\flows\namespace__PackagedProcessBuilder.flow-meta.xml  Cannot delete managed object
ERROR running force:source:deploy:  Deploy failed.

Which is confusing because I'm not trying to delete it. How can I activate it via the metadata API?

1 Answer 1

1

I suspect the error message I saw was a Salesforce bug. I found a workaround that works as long as I know the version of the process builder I am looking to activate.

Since v44 flow metadata has simply worked with the latest version instead of having versions in metadata. Prior to v44 flow activation status was stored in FlowDefinition. Despite Salesforce recommending to discontinue use of this, I can activate my managed flow by deploying a FlowDefinition object with the version number to activate.

namespace__PackagedProcessBuilder.flowDefinition-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<FlowDefinition xmlns="http://soap.sforce.com/2006/04/metadata">
    <activeVersionNumber>1</activeVersionNumber>
</FlowDefinition>

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.