I am having issues using the same code in two scenarios:
- From a ribbon button call revisionRequested which in turn calls removeOptions and
- from the form OnLoad, call removeOptions only.
The code below is my work around, but I what I originally tried was to pass the primaryControl
param from revisionRequested
to removeOptions
in which I made formContext = primaryControl I got an error.
function revisionRequested(primaryControl) {
var formContext = primaryControl;
formContext.getAttribute("statuscode").setValue(100000009); // Revision Requested
removeOptions(0, primaryControl);
Xrm.Navigation.openAlertDialog('Your revision request has been been submitted');
}
function removeOptions(executionContext, primaryControl) {
var formContext = null;
executionContext == 0 ? formContext = primaryControl : formContext = executionContext.getFormContext();
var statusCode = formContext.getAttribute("statuscode").getText();
var statusControl = formContext.getControl("header_statuscode");
if (Xrm.Page.ui.getFormType() !== 1 && statusCode.includes('Revision')) {
statusControl.removeOption(1);
statusControl.removeOption(100000000);
statusControl.removeOption(100000001);
statusControl.removeOption(100000002);
statusControl.removeOption(100000003);
statusControl.removeOption(100000003);
statusControl.removeOption(100000004);
statusControl.removeOption(100000005);
statusControl.removeOption(100000006);
statusControl.removeOption(100000007);
statusControl.removeOption(100000008);
}
}