Loading...

Dynamically Populate Owner Value (User or Team) in Power Automate

Dynamically Populate Owner Value (User or Team) in Power Automate
When building flows in Power Automate, sometimes we need more than just adding a dynamic value for complex scenarios (or at least for complex data types like polymorphic lookups). In this post, you will learn about how to set the value of the Owner field dynamically based on the value of another row's Owner field (which can be either User or Team).

Owner value from Trigger Output

In Dynamics 365/CDS, the row can be owned by either a user or a team. If we set the Owner column value based on the value of another row's Owner column using the Common Data Service (current environment) connector, it can be a bit tricky since we need to provide the EntitySetName (systemusers or teams) based on the value.

Example Scenario: Create a task for the Account row owner to verify when the Website of the Account is updated. The task needs to be assigned to the same owner as of the Account which can be a user or a team.

If we have to set the Owner column value from the triggering row (When a record is created/updated), we can use the flow expression below to handle both user and team table types.

UPDATED: Thanks Phil Cole for pointing out the conciser version of expression in the comment.

Expression with string concat
concat
(
triggerOutputs()?['body/_ownerid_type'],
'(',
triggerOutputs()?['body/_ownerid_value'],
')'
)

Expression with If statement
if
(
equals
(
triggerOutputs()?['body/_ownerid_type'],
'systemusers'
),
concat
(
'systemusers(',
triggerOutputs()?['body/_ownerid_value'],
')'
),
concat
(
'teams(',
triggerOutputs()?['body/_ownerid_value'],
')'
)
)
The format of the table type (logical name) properties of the lookup column in the trigger output is – _ownerid_type.

Owner value from Action Output

In the output of "Get a record", "List records", "Create a new record', "Update a record", and any other CDS (current environment) actions, the format of the lookup column is – [email protected].


If we have to set the Owner column value from the action row (Get a record), we can use the flow expression below.

Expression with string concat
concat
(
outputs('Get_a_record')?['body/[email protected]'],
's(',
outputs('Get_a_record')?['body/_ownerid_value'],
')'
)

Expression with If statement
if
(
equals
(
outputs('Get_a_record')?['body/[email protected]'],
'systemuser'
),
concat
(
'systemusers(',
outputs('Get_a_record')?['body/_ownerid_value'],
')'
),
concat
(
'teams(',
outputs('Get_a_record')?['body/_ownerid_value'],
')'
)
)

Based on the name/type of action, the expression needs to be changed accordingly. Take note that the item property of the "Apply_to_each" for array output (e.g. from List records action) does not require "body/" before the column name.
e.g.
  • items('Apply_to_each')?['_ownerid_value']
  • outputs('Create_a_new_record')?['body/_ownerid_value']
Expression for Apply to each
concat
(
items('Apply_to_each')?['[email protected]'],
's(',
items('Apply_to_each')?['_ownerid_value'],
')'
)

Expression for Create a new record
concat
(
outputs('Create_a_new_record')?['body/[email protected]'],
's(',
outputs('Create_a_new_record')?['body/_ownerid_value'],
')'
)

Summary

By using the "if" expression to check the table type (logical name) of the owner of the existing row, we can dynamically set the owner value of another row and specify the EntitySetName (systemusers or teams) dynamically in the expression.



Stay tuned for my next post where I will explain how to set the value of the Regarding field (or any polymorphic lookup field) dynamically based on the value of another record's Regarding field (which can be of any entity type).

Published on:

Learn more
Linn's Power Platform Notebook
Linn's Power Platform Notebook

A blog about Dynamics 365 and Power Platform (canvas apps in Power Apps and flows in Power Automate).

Share post:

Related posts

We need to talk about... Power Automate... Licensing

Next in my blog, I am going to cover a topic that has come up several times in recent conversations with clients.....Microsoft Licensing! part...

2 days ago

Flows getting triggered multiple times / missing callbackregistration record – Power Automate / Dataverse

Recently, we observed that one of our flows was getting triggered multiple times in our UAT environment; however, the flow was working properl...

4 days ago

Power Automate – Information about ‘Retry with AI vision’ functionality in Power Automate for desktop

We are announcing the introduction of the Retry with AI vision feature in error handling for UI and browser automation within Power Automate f...

4 days ago

How to Automate Post-Case Resolution Surveys in Dynamics 365 with Copilot and Power Automate (Preview)

Exceptional customer service doesn’t end when a support ticket is closed. In many cases, the most insightful feedback comes after the re...

4 days ago

Power Automate with a Service Principal (App Registration)

A “service account” for Power Automate with a Service Principal (App Registration) Dataverse—implemented as…

5 days ago

Power Automate – Reference previous prompts in Copilot for Power Automate desktop

We are announcing the ability to reference previous prompts in Copilot for Power Automate desktop in Power Automate. This feature will reach g...

5 days ago

Power Pages Solution Architecture Patterns: When to Use Liquid vs. JavaScript vs. Power Automate

In Power Pages, you can implement logic in multiple layers — Liquid (server-side), JavaScript (client-side), or Power Automate (external workf...

10 days ago

New Tool : ‘Cloud Flow Viewer’ for Power Automate Solutions

I’ve added Cloud Flow Viewer tool to my hobby project JayVish Problem Statement: Let’s say you’ve received a Dataverse solution—managed ...

11 days ago

Advanced Error Handling Patterns in Power Automate

When you start building a lot of Flows, you’ll start noticing that only checking values and if the actions succeeded only takes you so f...

11 days ago

Power Automate Cloud Flow | Disable an action

Did you know you can disable a flow action without removing it entirely by turning on the Enable Static Result toggle? When the flow runs, thi...

11 days ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy