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)

Pausing a function till Asynchronous call has retrieved data

(0) ShareShare
ReportReport
Posted on by 2,601

I'm creating a function which will take input parameters of

EntityName

EntityField

OptionSetDescription

and then return the optionset value.

I'm using SDK.Metadata.RetrieveAttribute to get back the option set items but the issue I have is that the RetrieveAttribute call is asynchronous and so the end of the main function is reached while the call is still running.

Ideally, I want the RetrieveAttribute  function to run synchronously so that it will get its results and then continue in the main function.

Any ideas how this can be achieved?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    jlattimer Profile Picture
    24,562 on at

    This of course is the nature of things when running asynchronously. RetrieveAttribute accepts a callback function as a parameter that gets called after the async operation has completed. Ideally you would add any logic that needs to be run after the operation into this function. It also accepts a passThroughObject parameter so you can optionally send an object from the calling function through to the callback. 

    If you really are in a pinch, you could always edit the SDK.Metadata.RetrieveAttribute function to make it run synchronously - but really you should only do this as a last resort. Things get easier if you learn to deal with the asynchronous programming model.

    Change this line:

    req.open("POST", _getUrl() + "/XRMServices/2011/Organization.svc/web", true);

    To:

    req.open("POST", _getUrl() + "/XRMServices/2011/Organization.svc/web", false);
  • CU21020959-0 Profile Picture
    2,601 on at

    Thanks Jason,

    This'll work for now till I can find a better solution.

  • Community Member Profile Picture
    on at

    HI Jason,

    I have a similar requirement where i need a CallBack URL which can be used to receive the response from third party REST async service?

    The requirement is - we have a third party REST service which process the request Asynchronously. The request parameters for that service includes a callback URL along with other standard request parameters. Upon completion of request, the response will sent back to Dynamics CRM via the CallBack URL.

    How we can get that CallBack URL? Any guidance on this is highly appreciated! Thanks in Advance.

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