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)

How to pass execution context as a parameter in Ribbon Workbench

(0) ShareShare
ReportReport
Posted on by 215

Hi guys,

So I have a custom qualify lead button that qualifies the lead using a js function the function requires the clientUrl and after doing some research i found out that i can get the client Url using context.getClientUrl, unfortunately i am unable to find a way in Ribbon Workbench to pass the context as a param.

Any advice is welcomed.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Filip,

    I believe you can change your function and retrieve url inside of it.

  • Verified answer
    Ivan Ficko Profile Picture
    1,380 on at

    You just need to call

    Xrm.Page.context.getClientUrl();

    inside your JavaScript function to get URL

  • Filip Vanchevski Profile Picture
    215 on at

    Yup thanks that did the trick :)

  • Community Member Profile Picture
    on at

    Hi All,

    What about using executionContext.getFormContext() ?

    As you know Xrm.Page is deprecated.

    Do you have any idea?

    -----------------

    Edit : Solution for executionContext is here https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/customize-dev/pass-dynamics-365-data-page-parameter-ribbon-actions 

  • Suggested answer
    Community Member Profile Picture
    on at

    Xrm.Utility.getGlobalContext().getClientUrl()

  • hgonzalez Profile Picture
    40 on at

    Today i guess Tommy Nurwantoro answer is the most useful if you need to pass the execution context from ribbon button. To use formContext instead of Xrm.Page in v9 for example

  • Suggested answer
    Silent Serenity Profile Picture
    55 on at

    Hi Filip Vanchevski and Everyone,

    For D365 CRM V.9 that implements fully the UCI (Unified Client Interface), below are the steps to pass the context as a param.

    1. You have to update your ribbon workbench command to add a CRM parameter "PrimaryControl" as shown in the image below:

    (If image doesn't show, then just Go to your Ribbon Workbench > Look the command that you wish to update > Then Add a CRM Parameter, the value would be "PrimaryControl")

    2. In your Webresource JS code, pass the primaryControl and use it as stated below:

    function QualifyLead(primaryControl) {

        var formContext = primaryControl; 

        // Sample of using it to for passing an Boolean value.
        formContext.getAttribute("logicalname of your field").setValue(true);

        var globalContext = Xrm.Utility.getGlobalContext();
        var clientUrl = globalContext.getClientUrl();
        console.log(clientUrl);

        // Some other codes that you wish to happen...

    }

    I have tested it and it works just fine.

    References: https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/customize-dev/pass-dynamics-365-data-page-parameter-ribbon-actions

    https://debajmecrm.com/2018/11/16/xrm-page-is-deprecated-with-version-9-0-how-do-i-get-the-clienturl-and-form-data-in-ribbon-actions/

    Thank you.

  • Suggested answer
    Vipin J Profile Picture
    1,603 on at

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

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

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