Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to Pass Context as a First Parameter to a function,when the function is called from Ribbon Button Click

Posted on by 2,715

Hello All,

      I want to know whether it is possible to pass " Context as a  First Parameter to a function,when the function is called from Ribbon Button Click",?

*This post is locked for comments

  • Suggested answer
    Vipin J Profile Picture
    Vipin J 1,583 on at
    RE: How to Pass Context as a First Parameter to a function,when the function is called from Ribbon Button Click

    Pass "PrimaryControl " as command parameter. Refer to the blog post here

    https://vjcity.blogspot.com/2019/06/how-to-pass-execution-context-as.html

  • CrmMad Profile Picture
    CrmMad 65 on at
    RE: How to Pass Context as a First Parameter to a function,when the function is called from Ribbon Button Click

    Great!!!. Your solution It's working with RibbonWorkBench

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to Pass Context as a First Parameter to a function,when the function is called from Ribbon Button Click

    See my post and mark it as verified if you found it useful.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to Pass Context as a First Parameter to a function,when the function is called from Ribbon Button Click
    I have resolved the issue where we were not able to pass the form context through ribbon button. As Xrm.page is going to be deprecated , we can use following approach to get it done.
    Note :Pass "PrimaryControl " as command parameter and use the same parameter in the java script function as first argument.
    Use Following to get the form attribute : formContext.getFormContext().getAttribute("fullname").getValue();
    This solution has worked for me. i hope this will work for you as well.
    Regards
    Neeraj Agrawal
  • Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Super User 2024 Season 1 on at
    RE: How to Pass Context as a First Parameter to a function,when the function is called from Ribbon Button Click

    Hi all,

    Is there any solution for the posted question?

    Thanks 

    Regards,

    AW

  • Suggested answer
    Syed Ibrahim Profile Picture
    Syed Ibrahim 6,257 on at
    RE: How to Pass Context as a First Parameter to a function,when the function is called from Ribbon Button Click

    hi RK,

    I dnt think it will be removed immediately . Still you can use it to get form metadata. Please find the below article for better clarity.

    community.dynamics.com/.../new-in-v9-what-s-that-with-xrm-page-being-deprecated

    Hope this helps

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: How to Pass Context as a First Parameter to a function,when the function is called from Ribbon Button Click

    Are you already using Dynamics 365 v9?

    We have not upgraded yet to the new client side model for our solutions (mostly on D365 8.2), but this should still work on v9 as well.

    For v9, you could be using Xrm.Utility.getGlobalContext:

    docs.microsoft.com/.../getglobalcontext

    We call a lot of actions from ribbon buttons, and are using the process.js library:

    github.com/.../processjs

    Hope this helps.

  • Ramakanta Profile Picture
    Ramakanta 2,715 on at
    RE: How to Pass Context as a First Parameter to a function,when the function is called from Ribbon Button Click

    Basically i need this because i want to pass some parameters to my Action,for which i can't use the Xrm.Page as it will be Deprecated in future

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: How to Pass Context as a First Parameter to a function,when the function is called from Ribbon Button Click

    Inside your function you can use Xrm.Page.context to get the context.

    If that's not it, please describe what you are trying to do.

  • Ramakanta Profile Picture
    Ramakanta 2,715 on at
    RE: How to Pass Context as a First Parameter to a function,when the function is called from Ribbon Button Click

    How i will able to get?

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans