Back to Basics # 69: Usage of Parameters from Modern Command Designer in Dynamics CRM


During certain scenarios we must pass parameters from the modern command designer so that they can be used inside JavaScript. In Classic Version of CRM, we have the option to pass execution context as first parameter under handler properties for a JavaScript type (Library)Webresource so that it can be used as a form context in Webresource(js) for customizations. In this post we see how to get the same form context by the usage of parameters concept that was present in Modern Command Designer, as an example contact main form was used to explain this scenario.

Step 1:

Open any model driven app as an example I have added contact form in my model driven app (Contacts Information App) and click on Contact table in the left side of the model driven app and select Edit Command Bar option as shown in the figure.

Step 2:

After Step 1, Select Main form of contacts  and click on edit as shown in the below figure.

Step 3:

After Step 2, add a new command and name it as CommandWithParam and in the right side of the window , look for Parameter 1 and select PrimaryControl as parameter1 and select the library as ContosoVaccination.Scripts.ContactForm.handleOnLoad

And click on save and publish as shown in the below figure.

Step 4:

After Step 3, open existing webresource cr5bc_contactmainform and under the method handleOnLoad write a function with parameter of your choice here as an example gave primaryControl and pass this to the related methods and from there write the specific logic to extract details that present in contact form here as an example first name of the contact was shown like the below code

ContosoVaccination.Scripts.ContactForm =


    handleOnLoad: function (primaryControl)




    __namespace: true


 function  calledfrommoderncommandbar(primaryControl)


        alert(“called from modern command bar using javascript”);

    let formContext = primaryControl;

    if (formContext!== null && formContext != ‘undefined’)

    { //first name logical name

        var firstname = formContext.getAttribute(“firstname”).getValue();

        alert(“First Name:” + firstname);



As shown in the below figure

Step 5:

After Step 4, open any contact record and click on CommandWithParam button , you should see alert “called from modern command bar using javascript” and then another alert “First Name: Venkata” as shown in the below figure .


  1. Make sure to publish all customizations and upload JavaScript file.
  2. Here I have concentrated on Primary Control Parameter part only, one can use other type of parameters like strings and multiple parameters like Parameter1 , Parameter2 etc., based on the need.
  3. Also observe, I have considered existing Webresource created earlier, you can also create new JavaScript Webresource.
  4. Observe, in code there we have used execution context like we use to do it in classic way of Web resources(js) implementations where one can write customizations with the help of form context.
  5. Microsoft Documentation: Here

Conclusion: In this way, one can easily pass parameters in Modern Command Designer in Dynamics CRM.

One thought on “Back to Basics # 69: Usage of Parameters from Modern Command Designer in Dynamics CRM

  1. Pingback: Back To Basics : Curated List of Articles in a Single Page – Common Man Tips for Power Platform, Dynamics CRM,Azure

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s