Skip to main content

Notifications

Hide SubGrid '+' / New Button button based on Parent status

Hide child  records sub grid + or Add New button

Some time we need to hide  '+' button or Add New button for child record grid..





You can do this by adding enable rule for + or Add New Button.

1. Open Child record customization in Ribbon workbench

2.  Select Entity so that we will able to modify command definition.

3. In Sub Gird, select + Add New {0} Button, right click and select Customize Command



4.  Add New Enable Rule


5. For Enable Rule.. Add steps, and select Custom JavaScript Rule

6. Set Custom rule properties as 
Default : true
Function Name: DisableSubGridNewButton
Invert Result : False
Library: JavaScript web resource where you added DisableSubGridNewButton function 
Parameters : None. 



JavaScript DisableSubGridNewButton Function 

-- When Form is ready only then hide +new or Add new Button for child records.
function DisableSubGridNewButton() {
    if (Xrm.Page.ui.getFormType() == 3) // Read Only
        return false;
    else
        return true;
}


-- based on Some values on Form

function DisableSubGridNewButton() {
    var IsMarried = Xrm.Page.getAttribute('new_status').getValue();

    if (IsMarried == 70000001) //un marriged
        return false// Hide button
    else
        return true//Show button
}


7. Add this enable rule to button Command



8. Save and Publish Customization.



Comments

*This post is locked for comments