Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

Run flow in user context

Posted on by

Hi Folks!

could you please help me how i can run flow in user context because we have enabled auditing on entity level not on all fields. we are tracking who is in modified by.
i have a schedule flow in which i am updating the record on change of calculated field.

2465.BRB.png

but it is disturbing our stats you know every time when this flow will get trigger on schedule base it will populate the user who created flow in modified by column.

help me how i can run this in user context. I know you will say "post this question on power automate community i did there too but there is no more traffic than here .

  • RE: Run flow in user context

    Good Evening a33ik

    Could you please help me in this Console App CRM Fetchxml.


    Thanks,
    ZG

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Run flow in user context

    Thanks! I'm glad I was able to help.

  • RE: Run flow in user context

    Hi a33ik morning.

    You are a champ thanks for your assistance.

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Run flow in user context

    Pre-Plugin that I mentioned is for update of existing records.

    But potentially you can use it for all set of operations what you can do is to pass "Former" user id to the Update to mark this as an Update from flow and use it accordingly in the code of the plugin. In this case you will have no need in impersonation.

  • RE: Run flow in user context

    Thanks a33ik


    according to you i have to write pre operation plugin on purchase vehicle plate column. changing plate column will set the value of plate on all other entities name column and i will set the modified by purchase vehicle into other entities modified by column but don't execute update request for other entities in pre operation plugin here power automate will play its role and will execute update steps am i right?

    pastedimage1606931038110v1.png

    pastedimage1606931057302v2.png

    pastedimage1606931067243v3.png


    am i right ?

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Run flow in user context

    There is no easy way on how you can set ModifiedBy field. But there is a workaround that would require additional code - rajeevpentyala.com/.../

  • RE: Run flow in user context

    Thanks a33ik really appreciated.

    what about the existing record they have in correct modified by. how i can set modified by column. is there any work around. if yes then i can simply add get a record action step before update a record action step and set the modified by column of update a record step  with get a record step  modified by column value.

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Run flow in user context

    Ok. Now it's clear and unfortunately there is no easy way for you to implement it.

    Flow "Update Record" doesn't have possibility to "Run-As" but pure WebApi requests have "impersonation" possibility. So here is what you can do:

    1. Compose WebApi Update request with impersonation - docs.microsoft.com/.../impersonate-another-user-web-api - you can play with it using PostMan. Here is article that describes how you can set your PostMan - docs.microsoft.com/.../setup-postman-environment

    2. Once 1 is completed - you can use "List Records" action in the flow to get records and include "Modified By" to your query.

    3. You can use Http Request with Azure AD request to call WebApi directly defining impersonate as user. Here is the post that describes how you can work with WebApi without the CDS adapter - www.itaintboring.com/.../

  • RE: Run flow in user context

    Thanks a33ik

    i know you are one of the champ.

    i have calculated field and i want to set an other column value on base of calculated field. i tried to trigger power automate flow on change of calculated field but not succeeded for workaround i have create flow and scheduled it when it update any record then it shows owner of the flow in modified by field.

    how i can achieve the same behavior in scheduled flow as in real time workflow where  ownership is who made changes?

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Run flow in user context

    Hello,

    I believe the main reason why you don't get a lot of responses on the Power Automate forum is because your question is... controversial and it's controversial because it's not clear what you mean with "User Context" and scheduled flow. User Context makes sense when user causes an action that triggers the flow (like Create/Update/Delete record or something user-initiated).

    So in order to give you any feedback - how do you see "User Context" in your scenario of scheduled flow?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans