Flows triggered from different environments when a backup is restored

Recently faced a situation where a production flow was being triggered if a record was added to the triggering entity in a lower environment and the flow had the current environment connector configured on it, strangest situation I’ve encountered.

A deeper investigation lead to a recognized bug by Microsoft on callbacksregistrations that are created at the backend when you turn a CDS trigger based flow on. All is good until you decide to restore the environments backup or copy the environment to another environment as those callbackregistrations to your flows do not get reset and are still pointing to the Flows of the environment you took the restore of, this causes the flows to trigger even if the environment is different. Unfortunately, there is no resolution yet and we have to wait till end of October to have this bug fix deployed to the platform, however below is a detailed work around on how to get rid of those bad call back registrations.

Resolution:
First identify the callbackregistration id’s on the entity your flow is being trigger off of. Todo so you will need to execute the below query on your effected environment(the environment you restored the backup to)

https://name.crm.dynamics.com/api/data/v9.0/callbackregistrations?$filter=entityname%20eq%20%27TypeEntitySchemaNameHere%27%20and%20message%20eq%201

You’ll replace your environment url, TypeEntitySchemaNameHere with your entity schema name and the 1 at the end represents the type of trigger so follow table below for the relevant type

– Create = 1,

– Delete = 2,

– Update = 3,

– CreateOrUpdate = 4,

– CreateOrDelete = 5,

– UpdateOrDelete = 6,

– CreateOrUpdateOrDelete = 7

Once we have our url created and excuted, you’ll recieve a json message in return look for all callbackregistrationid’s and delete them one by one following the process below.

“callbackregistrationid”:”d87bac31-f308-eb11-a813-000d3a988097″

Goto your restored environment and open up the developer console(F12 for chrome), and execute command below under console tab by replace the callbackregistration id

fetch(‘http://envname.crm.dynamics.com/api/data/v9.0/callbackregistrations(17asd7d2-40db-ea11-a813-000d3a579b99)’, {​​ method: ‘DELETE’}​​)

this will delete the callbackregistration with the original environment. Make sure you do this for all callbackid’s against that entity, then goto your flow and turn off the flow, edit the flow and save it again and turn it back on. After turning the flow on you will notice that a new callbackregistrationid is generated when you execute the first query to get all callbackregistrationid’s. This means that your trigger has now been registered against current CDS, now all you need to do is repeat this for all the flows you have in your environment that have a CDS trigger point, all the best!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s