Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Run Workflow as Owner of Workflow

Posted on by 90

Hi,

I have a workflow that is run as the owner of the workflow when creating and completing Tasks. It needs to be run as the owner due to how it updates a closed Opportunity as well as completing the Task.

But, doing this sets the modifiedby or completed by fields to the owner of the workflow. Is it possible to capture the user instead of the owner?

As in: 

User A completes the Task, the workflow runs, but then capture user A and append the user (systemuserid) to the modifiedby or completedby fields? 

Any ideas?

  • Suggested answer
    Amit Katariya007 Profile Picture
    Amit Katariya007 8,525 Super User 2024 Season 1 on at
    RE: Run Workflow as Owner of Workflow

    Hello Monty,

    This is the OOB workflow limitation.

    As you are already in the right path you will just need to do some customization that create a plugin which will create Task after trigger and populate the owner as the calling user in the task.

    refer below code where it is mentioned how we can get the Initiating user.

    https://crmchap.co.uk/determining-the-initiating-user-details-on-a-c-plug-in-dynamics-365-for-customer-engagement/

    https://www.inkeysolutions.com/blogs/execute-a-plugin-in-the-context-of-the-logged-in-user-or-calling-user-or-system-user-in-microsoft-dynamics-365/

    Then using below code you can set the created by and modified by in the plugin.

    Override createdon, modifiedon, createdby, modifiedby in Dynamics 365/ CRM {CRM Tips from the Vault} - Debajit's Power Apps & Dynamics 365 Blog (debajmecrm.com)

    Change Createdby/Modifiedby Field at Runtime in Dynamics CRM Plugin | Microsoft Dynamics 365 CRM Tips and Tricks (inogic.com)

    Thank you,

    Amit Katariya

  • Monty_270311 Profile Picture
    Monty_270311 90 on at
    RE: Run Workflow as Owner of Workflow

    "I have a workflow that is run as the owner of the workflow when creating and completing Tasks. It needs to be run as the owner due to how it updates a closed Opportunity as well as completing the Task."

  • Suggested answer
    Amit Katariya007 Profile Picture
    Amit Katariya007 8,525 Super User 2024 Season 1 on at
    RE: Run Workflow as Owner of Workflow

    Hello,

    Can you make your workflow as the Real Time and make below change in the workflow.

    pastedimage1652441741035v1.png

    Thank you,

    Amit Katariya

  • Monty_270311 Profile Picture
    Monty_270311 90 on at
    RE: Run Workflow as Owner of Workflow

    Hi,

    So you can't capture triggering user in a custom workflow or plugin?

  • Suggested answer
    Amit Katariya007 Profile Picture
    Amit Katariya007 8,525 Super User 2024 Season 1 on at
    RE: Run Workflow as Owner of Workflow

    Hello Monty,

    It is not possible because workflow will run on behalf of triggering user.

    Unless it will run in calling users context this will be not possible.

    Thank you,

    Amit Katariya

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