web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Use C# await in Custom Workflow Activity

(0) ShareShare
ReportReport
Posted on 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

I have the same question (0)
  • Zibba360 Profile Picture
    on at

    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?

  • Kokulan Profile Picture
    18,054 on at

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

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    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.

  • Zibba360 Profile Picture
    on at

    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans