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 :
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

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 83 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans