Sometimes it is necessary to control the buttons on the sub-table according to the approval status of the main table, for example, if we have a requirement approval, we can no longer upload the file.
First open the visual Ribbon Editor,
For example, we can use the Enable Rules–> Customrule with JS to control whether the button is displayed:
JS function:
First, the state of the primary table is fetched with OData, and then the state of the primary table is used to determine whether to display:
var approvalstatus = null;
function Controlupload () {
var Marketingplan = Xrm.Page.getAttribute ("New_marketing_planid"). GetValue ();
if (Marketingplan! = null) {
var filter = "New_marketing_planset? $select =new_approval_status,new_monthid& $filter =new_marketing_planid eq Guid ' "+ marketingplan[0].id +" ' ";
var result = Query_ent (filter);
if (result! = NULL && Result.new_approval_status! = null) {
Approvalstatus = Result.new_approval_status
}
}
if (approvalstatus! = null && (Approvalstatus.value = = 2 | | approvalstatus.value = = 3)) {
return false;
}
else {
return true;
}
}
Dynamic CRM 2013 Learning Notes Series Rollup
Dynamic CRM 2013 Learning Notes (18) using the JS Control sub-table custom button According to the primary table state