Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Pass JavaScript Execution Context

Posted on by 676

I have function1 and function2. Function1 is triggered when save button is click (Xrm.Page.data.entity.addOnSave(function1). Function2 is being called from Function1.

Now, i need to pass "ExecutionContext" to function2 because i have to check for the "Save Event Mode (Save/SaveAndClose/SaveAndew)". Is this possible? Or are there any way to check for the Save Event Mode on function2?

*This post is locked for comments

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Pass JavaScript Execution Context

    Hi,
    You could Pass execution context as the first parameter for the function1 while registering the function1 on save and then pass the same execution context to function2.
    Pass the execution context to function1 as described in the link below.
    http://www.magnetismsolutions.com/blog/paulnieuwelaar/2012/06/10/dynamics_crm_2011_javascript_get_attribute_from_onchange

    Then, use the code below.

    Xrm.Page.data.entity.addOnSave(function1(executionContext));

    Inside function1, call

    function2(executionContext);

    Now the execution context can be used by both the functions.
    Hope this helps.

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Pass JavaScript Execution Context

    Hello,

    I believe you can add executionContext as a parameter for both functions and just pass it from first function to second. What kind of issues do you experience?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans