Power Automate Step-by-Step for the System Admin – Day 4 Blog

Now that we have The Setup completed for a Power Automate Flow, set up the first flow action, and Applied it to each, it’s time to create a task or record.

If you haven’t gone through Days 1-3, please take a moment to do that.

Day 1: The Set up

Day 2: List Action Records

Day 3: Apply to Each

As a reminder, our scenario is to complete the following:

The Scenario

We want to run an advanced find query against a Dynamics 365 custom entity, loop through the result set, and create a task when we find a data anomaly in our system. For example, perhaps contacts can only be linked to Active Accounts, so let’s find all contacts linked to inactive accounts.   We can then create a task for somebody to investigate each Contact linked to an Inactive account.

To build on Day 3:

Create a Task in Dynamics 365

(23) Click on the “Add an action” button inside the “Apply to each” block.

(24) Type “Create” in the search box, and select the “Create a new record” action using the Common Data Service (current environment) connector.

(25) Select “Task” for the entity.

You will see all of the fields from the Task entity.  We can enter data into any of these fields.  And, the key is, we can use values from the record we are currently processing!

So, let’s keep this simple, and enter the following:

  • Subject: Contact <Fullname> linked to inactive Account
  • Due Date: Now
  • Owner: Select the owner of the Contact record
  • Priority: 2
  • Regarding: the Contact

(26) Enter the Subject, using the FullName of the Contact record we are processing.  In the dynamic content search window, type “name”.  Any Contact field with “name” in it appears.  Select “fullname” from the list.

(27) You can now add the other text you want to see around that full name variable, like this:

Note: no need for “equals” signs, or “quotes”.  Just type in the text.  Power Automate does a phenomenal job of stringing together text and variables of different types.  (Note: the Compose action is a quick and dirty way of showing you variable values in your flow trace.)

(28) Place your cursor into the due date, and click on the “Expressions” tab in the dynamic content window.

(29) Type “now” in the expression, and select the utcNow field (I click the TAB key to make that action appear in the expression block precisely as shown.)   Click OK to add this expression to the Due Date field.

Result:

(30) Now, set the Task Owner to the Contact Owner by searching Owner from the Dynamic Content pane, and selecting the Owner (Value) field from the list.

System Admins know that lookups have an entity, type, and value.  The Value stores the GUID, which is what we want. And you would think that, like other fields, that should work. However, if you try to run the flow now, you would get an error:

The issue is that you need to basically supply the entity name, along with the GUID.  The short answer is: add the PLURAL of the technical entity name to the GUID value, in this case “systemusers”.  And surround the GUID (value) with parenthesis.

(Note: in the CRM System Admin entity window, the name you want is almost always the plural of the NAME field.  Just add an “s” to the Name.  contacts.  accounts. Leads.  Note that you might be tempted to then use the “Plural Name” field value, but (a) the Case is likely wrong, and (b) for entities like Cases, it’s very wrong.  (Use “incidents()” to wrap around a Case GUID.)   

Easier to show than explain:

So, any time you want to set the owner in a new entity record you create with Power Automate, the correct syntax is:

systemusers(<Owner GUID Value>)

Note the open “(“ parens and close “)” parens.

(31) Just select the desired Priority from the list:

(32) Set the Regarding to the Contact.  This will both link this task to this Contact’s timeline AND provide an easy way to navigate to the Contact from the Task by clicking the regarding hyperlink in the task.  (You can also create navigable URL’s so users can click on records NOT linked via the Regarding field.)

  • (a) Enter “Contact” into the Dynamic Expressions search box.
  • (b) Select “Contact”, the unique identifier of the Contact.

  • (c) Now, we have to add the plural name, and an open and close parens around our “Contact” variable.  End result:

This is the full definition of our Create Task action:

(33) Click SAVE to Save your flow.  It is now ready to test!

JUMP TO DAY 5: TESTING

Categories:

Leave a Reply

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