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);
}
}
Possibly you might have missed to add the
PrimaryControl
CRM parameter in ribbon command. Then you don’t needXrm.Page
, instead you will get the context directly in the first parameterexecutionContext
. Read more