I need a JS function to hide a button depending on the value of a field of the record.
I added the button on Ribbon Workbench and associated it with a command, which is associated with the JS action.
I set the Crm Parameter "Primary Control" to pass the execution context to the JS function.
I retrieved the field value by using the formContext, but how can I refer to the button itself to change its value?
Assuming that the executionContext refers to the button, I figured out I could use the "executionContext" itself to call the "setDisabled" method, but the intellisense suggests to me that it's not the right option.
I also figured out I should use the formContext to get the "name" attribute of the button, but where can I find it/which component should I look at? (As I added it from the Ribbon Workbench tool, I don't know where I should look at to see its property from CRM settings).
Moreover, it doesn't make sense to me, as the button is the executionContext itself, is it correct?
What I have tried:
*** On Ribbon Workbench ***
- I added a button
- I added a new command
- I associated the previous Custom Javascript Action to the command
- I added a CRM parameter with the value "Primary Control" to the action to pass the
executionContext to the JS function
*** On JS code ***
function hideButton(executionContext){
var formContext = executionContext.getFormContext();
var state = formContext.getAttribute("statecode").getValue();
if (state .getValue() == 1) {
}
}