In this blog, we will show how to hide and show the command bar based on a field value.

First take any Field by your choice, i am taken a two options set 

Create a web resource with below code 

function hidebar(executionContext){
    formContext=executionContext.getFormContext();
    var hidecbar=formContext.getAttribute(“vinay_hidecbar”).getValue();
    if(hidecbar==Yes){
        formContext.ui.headerSection.setCommandBarVisible(false);
    }
    else{
        formContext.ui.headerSection.setCommandBarVisible(true);
    }
}

change the above code based on your requirements and add it to the field properties

Now Publish the changes

Next, Go to the app and test the changes.

1.. command bar “Visible” on “NO”

2… Command “Not Showing” on “Yes”