Power Automate the enforcement of naming convention on CDS|Dynamics 365 workflows

Posted by

Enforcement of the naming convention, as described in my previous blog post, can be Power Automated. The CDS|Dynamics 365 workflow properties (attributes value) can be used to compose the prefix for the workflow naming.

Workflow propertiesValuesPrefix if true
mode0 (Background), 1 (Real-time)RT>
ondemandtrue, falseOD
subprocesstrue, falseCW
triggeroncreatetrue, falseCreate
triggeronupdateattributeliststatecodeUpdate(statecode)
triggeronupdateattributelistowneridUpdate(ownerid)
triggeronupdateattributelistattributesUpdate(attributes)
triggerondeletetrue, falseDelete

Here is the overview of the flow:

The List Workflow records will get the unmanaged workflows (category: 0 – classic Common Data Service workflows) from a specific solution.

For every workflow record the prefix is composed by the following expressions:

if(bool(items('Apply_to_each_workflow')?['mode']),'RT>','')
if(items('Apply_to_each_workflow')?['ondemand'],'OD|','')
if(items('Apply_to_each_workflow')?['subprocess'],'CW|','')
if(items('Apply_to_each_workflow')?['triggeroncreate'],'Create|','')
if(not(empty(items('Apply_to_each_workflow')?['triggeronupdateattributelist'])),concat('Update(',items('Apply_to_each_workflow')?['triggeronupdateattributelist'],')'),'')
if(items('Apply_to_each_workflow')?['triggerondelete'],'Delete','')

In the condition it is checked if the workflow name does not start with the prefix already. If true, the new workflow name is composed based on the prefix and its current name, making sure that it does not exceed the maximum length of 100 characters.

if(greater(length(replace(concat(outputs('Compose_Prefix'),': ',items('Apply_to_each_workflow')?['name']),'|:',':')),100),substring(replace(concat(outputs('Compose_Prefix'),': ',items('Apply_to_each_workflow')?['name']),'|:',':'),0,100),replace(concat(outputs('Compose_Prefix'),': ',items('Apply_to_each_workflow')?['name']),'|:',':'))

The workflow record is deactivated in the first Update action, then the workflow name is updated and in the last Update action the workflow record is activated again.

Now when I test this with the following custom workflow:

the flow will rename this workflow like this:

In this way the naming convention for CDS|Dynamics 365 workflows can be enforced with the help of Power Automate flow.

In the next blog post I will show how to enforce the naming convention on Power Automate flows, with the help of Power Automate flow.

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *