Micrsoft Dynamics CRM: Facing troubling while executing js web resouce for crm button

91 views Asked by At

I created a button in an account form entity by ribbon workbench and then I tried to create a javascript code. When executed the code is just fetching the account id and showing that id in the alert and then I registered that file to that button by ribbon workbench action command. I wrote the below code, please let me know what is wrong with that.

I am expecting an alert box with that id, but nothing is happening

The code is below:

fetch = {

    fetchingacountid: function(executionContext){

        var formContext = Xrm.Page.context.getFormContext();
        var accountId = formContext.data.entity.getId();
        alert("The ID of the current account is: " + accountId);
    }

}
1

There are 1 answers

0
Arun Vinoth-Precog Tech - MVP On

Possibly you might have missed to add the PrimaryControl CRM parameter in ribbon command. Then you don’t need Xrm.Page, instead you will get the context directly in the first parameter executionContext. Read more

enter image description here