Uni = {
__namespace: true
};
};
Uni.Waikato = {
__namespace: true
};
};
__namespace: true
};
};
__namespace: true
};
};
Uni.Waikato.Es.Uni_agreement.subStatussCache = null;
Uni.Waikato.Es.Uni_agreement.GetSubStatus = function (executionContext) {
if (arguments === null || arguments.length === 0 ||
typeof arguments[0].getFormContext !== "function") {
Xrm.Navigation.openAlertDialog({ text: "executionContext has not been passed into function:" + arguments.callee.name });
return;
}
var formContext = executionContext.getFormContext();
var subStatus = formContext.getControl("uow_substatus1");
Uni.Waikato.Es.Uni_agreement.subStatussCache = subStatus.getOptions();
if (arguments === null || arguments.length === 0 ||
typeof arguments[0].getFormContext !== "function") {
Xrm.Navigation.openAlertDialog({ text: "executionContext has not been passed into function:" + arguments.callee.name });
return;
}
var formContext = executionContext.getFormContext();
var subStatus = formContext.getAttribute("uow_substatus1");
if (agreementStatus.getValue() != null) {
var subStatusControl = formContext.getControl("uow_substatus1");
var optionsToAdd;
switch (agreementStatus.getValue()) {
case 942210002: //Pending
optionsToAdd = [942210000, 942210002]; //Negotiation, Signing
break;
case 942210004: //Expired
optionsToAdd = [942210001, 942210003]; //Action Required, Not Renewing
break;
default:
break;
}
if (optionsToAdd != null && Uni.Waikato.Es.Uni_agreement.subStatussCache != null) {
subStatusControl.clearOptions();
for (var i = 0; i < optionsToAdd.length; i++) {
var newOption = Uni.Waikato.Es.Uni_agreement.subStatussCache.find(element => element.value == optionsToAdd[i]);
if (newOption != null) {
subStatusControl.addOption(newOption);
}
}
subStatusControl.setVisible(true);
} else {
formContext.getControl("uow_substatus1").setVisible(false);
}
formContext.getControl("uow_substatus1").setVisible(false);
}
}