Skip to main content
Post a question

Notifications

Community site session details

Community site session details

Session Id : cVJ1KBieYbX0IowM/inMIV
Microsoft Dynamics CRM (Archived)

Use C# await in Custom Workflow Activity

Like (0) ShareShare
ReportReport
Posted on 26 Feb 2018 10:18:11 by

How to use C# await in Custom Workflow Activity.

Scenario: I am creating a record and then retrieve a related record of the one I've just created using QueryExpression and filtering by the id of the record I've just created. I want to await the creation of the record until the QueryExpression finds the related record. 

*This post is locked for comments

  • Zibba360 Profile Picture
    on 27 Feb 2018 at 06:29:42
    RE: Use C# await in Custom Workflow Activity

    My bad, actually it's a web service. The Web service receives data outside of crm then updates an entity field, that then triggers a crm workflow which then creates a related record. Now the web service waits for the workflow to trigger and create the record, once it is created, the web service returns a response with data from the created related record.

  • Suggested answer
    gdas Profile Picture
    50,089 Moderator on 26 Feb 2018 at 15:22:27
    RE: Use C# await in Custom Workflow Activity

    Hi ,

    You can use await async in custom workflow, there is no bound to use c# functionality inside custom workflow.

    You can refer below url -

    [View:https://stackoverflow.com/questions/16960312/implementing-asynccodeactivities-using-c-sharp-async-await]

    Hope this helps

    Good luck.

  • Kokulan Profile Picture
    18,054 on 26 Feb 2018 at 14:10:06
    RE: Use C# await in Custom Workflow Activity

    Is your create and querying done in the same custom workflow activity?

  • Zibba360 Profile Picture
    on 26 Feb 2018 at 13:46:21
    RE: Use C# await in Custom Workflow Activity

    Currently, I check if the returned EntityCollection has any entity...if not, the thread sleeps for 2 seconds and tries again (3 times) in a for loop. If still no entities, it returns a message, else takes the first record in EntityCollection.

    Any better way of doing this?

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,435 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,567 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Loading complete