Cloud Flows with Dataverse Trigger Not Working After Solution Import
This post will explain how you can identify the root cause of the issue and
resolve it if some of the cloud flows with Dataverse trigger are not getting triggered after solution import even though the status of the flow is "On".
After one of the deployments, the test team reported that some of the cloud
flows are not getting triggered when a row is added or updated in Dataverse.
Most of the flows are working and it only happens for some of the flows, so
it is not because of the "Background operations" being disabled in the environment in "Administration Mode". We checked the flow and the status of the flow is also "On". There is no
error message about the problem with the flow's trigger. When we turn
off the flow and turn it on, the changes in Dataverse start triggering the
flow again. Upon further investigation, the affected cloud flows are missing
a related row in CallbackRegistration table.
What is CallbackRegistration table?
There is no official documentation about CallbackRegistration table but
it stores the trigger information of the async background operations (async
classic workflow, cloud flows but not async plugin) such as trigger message
(e.g. Create, Update, Delete), Table name, Scope, Filtering Columns,
Filtering Expression (e.g. statecode eq 0), Run as User, etc.
In this case, the trigger information of the affected cloud flows in
the CallbackRegistration table were deleted during the solution
import somehow so that the flows were not getting triggered even though the
flow status is "On".
How do I find the affected cloud flows when I experience the same
issue?
There were dozens of flows in our system, so we could not possibly test the
trigger of all flows manually. I wrote a small SQL query to query all activated cloud flows (the ones with modern flow category in workflow table) and show the related CallbackRegistration data using SQL 4 CDS XrmToolBox Tool. You can filter the flows based on the unique name of the solutions and non-Dataverse trigger flows (e.g. manual flow, recurring flow, flows with other triggers such as SharePoint, Outlook, etc.) can be excluded from the query with the name of the flows.
SELECT friendlyname, workflowid, workflow.name, workflow.statecodename, callbackregistration.name, callbackregistration.entityname, callbackregistration.messagename, SUBSTRING(clientdata, CHARINDEX('triggers', clientdata), 70) from workflow
LEFT OUTER JOIN callbackregistration ON workflowid = callbackregistration.name
LEFT OUTER JOIN solutioncomponent ON workflowid = solutioncomponent.objectid
LEFT OUTER JOIN solution on solutioncomponent.solutionid = solution.solutionid
WHERE category = 5
AND statecode = 1
AND solution.uniquename IN ('Solution1', 'PowerPlatformPlayground')
AND workflow.name NOT IN
(
'Name of the Child Flow with Manaul Trigger 1',
'Name of the Recurring Flow 2',
'Name of the Flow with other trigger 3'
)
ORDER BY callbackregistration.name, workflow.name
In the screenshot below, cloud flows from row 1-13 do not have related CallbackRegistration data. But based on the name of the flow or the trigger value in the clientdata, we can identify that all of the flows are instant flows with manual trigger except the flow in row 11 which has the SharePoint folder. If any of the flows with Dataverse trigger are missing related CallbackRegistration data (NULL value for the columns 5-7), it means those flows are not getting triggered even though the status is "On".
I am getting the following error while running the SQL query above in SQL 4 CDS Tool.
"Conversion failed when converting from a character string to uniqueidentifier."
It happens when the name column of the CallbackRegistration table contains some text value other than the GUID of the workflow row ID. Since CallbackRegistration table is not documented, I am also not sure how it can be joined effectively to the workflow table (where the cloud flows are stored)
If it happens in your environment, query the cloud flows and CallbackRegistration table in a separate query and compare manually in the Excel file.SELECT friendlyname, workflowid, workflow.name, workflow.statecodename, SUBSTRING(clientdata, CHARINDEX('triggers', clientdata), 70) from workflow
LEFT OUTER JOIN solutioncomponent ON workflowid = solutioncomponent.objectid
LEFT OUTER JOIN solution on solutioncomponent.solutionid = solution.solutionid
WHERE category = 5
AND statecode = 1
AND solution.uniquename IN ('Solution1', 'PowerPlatformPlayground')
AND workflow.name NOT IN
(
'Name of the Child Flow with Manaul Trigger 1',
'Name of the Recurring Flow 2',
'Name of the Flow with other trigger 3'
)
ORDER BY friendlyname, workflow.name
SELECT name, entityname, messagename
FROM callbackregistration
ORDER BY name
I am not allowed to use XrmToolBox in my organisation. Is there any other option?
In that case, you can query the list of cloud flows and CallbackRegistration table with the WebAPI query below.
https://«OrgName».«CrmRegion».dynamics.com/api/data/v9.2/workflows?$select=workflowid,name&$filter=category%20eq%205%20and%20statecode%20eq%200
https://«OrgName».«CrmRegion».dynamics.com/api/data/v9.2/callbackregistrations?$select=name,entityname,message
If I encounter such an issue, shall I report it to Microsoft?
Microsoft product team is aware of some scenarios where while importing the solution issue with Callback Registrations happens and they are working to fix those issues. Some of the scenarios are:
- When an environment is copied.
- Current Flow owner has limited privileges in the Org where the solution flow is imported.
Other than the scenarios above, if you encounter such an issue after solution import, you can report it to Microsoft Support so that the product team can work together to get the details and find the reason and fix the issue for other scenarios as well.
Until the issue is fixed how can I prevent it from happening in my solution import?
You can add a step in your CI/CD pipeline to turn off all the flows from the solution and turn those back on after solution import.
Are there any other scenarios that could cause this issue?
I have not experienced it personally but there are some incidents where the old CallbackRegistration data of the cloud flows were not getting deleted during the solution import so that the new ones are not created. For that issue, a Microsoft Support ticket was raised and it was resolved by re-importing the solution again after the support team deleted the old CallbackRegistration data.
Summary
If you are experiencing an issue with the Dataverse cloud flows which are not getting triggered after solution import, you can use a SQL query using SQL 4 CDS XrmToolBox Tool to identify the affected cloud flows which are missing a related CallbackRegistration data. You can also use a PowerShell script to turn off/on all the flows after solution import and part of the CI/CD pipeline to prevent this issue too.
This article was a lifesaver today. Appreciate it!
ReplyDeleteSecond the comment above. I was tearing my hair out. Thanks so much for publishing this.
ReplyDelete