hi
It is not possible to hide "Add new & Add Existing" buttons from the quick view form of the sub-grid. However, you can disable the "Add new & Add Existing" buttons on the sub-grid itself so that users are not able to add new records to that sub-grid.
To do this, follow the steps below:
Open the form in the form editor and navigate to the sub-grid you want to modify.
Click on the "Controls" tab and select the sub-grid control.
In the "Properties" section, expand the "Behavior" section.
Set the "Add new record" and "Add existing record" properties to "false".
Alternatively, you can add a JavaScript function to disable these buttons based on a certain condition. For example, if you want to disable the "Add new" button when the user is trying to create an entry from Table X, you can use the following code:
function disableAddNewButton() {
var gridControl = Xrm.Page.getControl("yourSubGridControlName");
var addButton = gridControl.getControl("addButton");
addButton.setDisabled(true);
}
function checkForTableX() {
var entityName = Xrm.Page.data.entity.getEntityName();
if (entityName === "tablex") {
disableAddNewButton();
}
}
Xrm.Page.data.entity.addOnSave(checkForTableX);
This code will disable the "Add new" button on the sub-grid when the user is trying to create a record from Table X. The addOnSave function is used to trigger the checkForTableX function whenever a record is saved on the form.
DAniele