Hi,
I want to set the visibility of a ribbon button by using JavaScript; the button will be visible if the state is "disabled".
I wrote the following code, but I'm not sure if it's correct:
onLoad = function (executionContext) {
        var formContext = executionContext;
        var state = formContext.getAttribute("state").getValue();
        if (state.getValue() == 1) {
            formContext.getControl("myRibbonButtonName").setDisabled(true);
        }
        else {
            formContext.getControl("myRibbonButtonName").setDisabled(false);
        }
    };
I will then add the function above to the OnLoad event handler in the Form Properties:

Does it make sense?
I have the following doubts:
- is it correct to use the getAttribute method (line 3), or should I better access the state differently?
- is it correct to add the function to the OnLoad  event of the entity form, or should I set the configuration in the Ribbon Workbench instead (and how)?