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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

how to pass variable out of Xrm.WebApi callback?

(0) ShareShare
ReportReport
Posted on by 1,030

pxLstGuid.PNG

Alert dialog comes up "undefined".  Why?

I have the same question (0)
  • Joana Pinto Profile Picture
    740 on at

    Hi mardukes,

    When does your function someOtherOnChangeEvent() is called? All those functions you are calling are async calls. Probably, when you are calling someOtherOnChangeEvent(), the Sdk.pxLstGuid is not filled yet, because it is being filled on an async function. That's why he is undefined.

  • Martin Donnelly Profile Picture
    1,030 on at

    Sorry!  I knew that would be a question.  The series of asyncs end in adding a custom view to a lookup.  The someOther is that lookup field.  So, I am certain it is completed before I select the value (because it is coming from my custom view.)

    I even tried ExecutionContext.SharedValues and got the same result.

    thank you for looking.

  • Martin Donnelly Profile Picture
    1,030 on at

    My goal is to not have to find the pricelevelid a second time since I have it in hand during the onLoad.

  • erhan.keskin Profile Picture
    2,253 on at

    Hi,

    Please check if Sdk.pxLstGuid's value has a valid value. If so, convert the value to string.

    Regards,

  • Martin Donnelly Profile Picture
    1,030 on at

    Thanks.  result["_defaultpricelevelid_value"] is one of the arguments to the next async.  I know the next function is receiving it and (as pretty much everything in javascript) it's a string.  Hence my question, why is the alert coming up "undefined".

  • Joana Pinto Profile Picture
    740 on at

    I think what is happening is that you have two different events: the one that fills your pxtLstGuid (where there are all those async calls) and the other associated to the lookup field. So when your second event is triggered, it will probably load all javascripts again and then your context is lost, hence the variables are undefined.

    So I think you will have to get the attribute again. Or create a hidden field which you will populate on the first event, so that you can retrieve it with the formContext.getAttribute("attribute_name").getValue().

  • Manish Jain Profile Picture
    50 on at

    This url might help if you are using response of one async call in next call based on output of first

    debajmecrm.com/.../

    Thanks

  • Manish Jain Profile Picture
    50 on at

    This url might help if you are using response of one async call in next call based on output of first

    debajmecrm.com/.../

    Thanks

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
11manish Profile Picture

11manish 151

#2
ManoVerse Profile Picture

ManoVerse 149 Super User 2026 Season 1

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 66 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans