web
You’re offline. This is a read only version of the page.
close
Skip to main content
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)
  • Suggested answer
    Vipin J Profile Picture
    1,603 on at
    RE: How to pass execution context as a parameter in Ribbon Workbench

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

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

  • Suggested answer
    Silent Serenity Profile Picture
    55 on at
    RE: How to pass execution context as a parameter in Ribbon Workbench

    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.

  • hgonzalez Profile Picture
    40 on at
    RE: How to pass execution context as a parameter in Ribbon Workbench

    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
    Community Member Profile Picture
    on at
    RE: How to pass execution context as a parameter in Ribbon Workbench

    Xrm.Utility.getGlobalContext().getClientUrl()

  • Community Member Profile Picture
    on at
    RE: How to pass execution context as a parameter in Ribbon Workbench

    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 

  • Filip Vanchevski Profile Picture
    215 on at
    RE: How to pass execution context as a parameter in Ribbon Workbench

    Yup thanks that did the trick :)

  • Verified answer
    Ivan Ficko Profile Picture
    1,380 on at
    RE: How to pass execution context as a parameter in Ribbon Workbench

    You just need to call

    Xrm.Page.context.getClientUrl();

    inside your JavaScript function to get URL

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: How to pass execution context as a parameter in Ribbon Workbench

    Filip,

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

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans