I do have a requirement to block a certain related option in a B Panel when a condition is met. To get that condition data one API must be executed. Hence I wrote the below code in the B Panel.
if (args.commandType == "LSTOPT" && args.commandValue == "5") {
await this.getConfigCode(args, PRNO);
this.log.Info("validation ok ");
if (this.configCode == "0") {
this.log.Info("inside validation");
alert("inside validation");
args.cancel = true;
}
}
private async getConfigCode(args: CancelRequestEventArgs, itemNumber: String) {
const myRequest = new MIRequest();
myRequest.program = "MMS200MI";
myRequest.transaction = "Get";
myRequest.record = { ITNO: itemNumber };
myRequest.outputFields = ["CHCD"];
return MIService.Current.executeRequest(myRequest).then(
(response: IMIResponse) => {
//Read results here
for (let item of response.items) {
this.log.Info(`2: Config Code: ${item.CHCD}`);
this.configCode = item.CHCD;
}
}).catch((response: IMIResponse) => {
//Handle errors here
this.log.Error(response.errorMessage);
this.configCode = "";
})
}
But my problem is that regardless of the condition, the panel moves to the related option. When I put args. cancel at the beginning function it works. If I do this way I need to write another branch in my if condtion to proceed to the related option when the condition is not satisfied.
When I check the logs, it also seems to be okay.
Config code 0
validation ok
Inside validation
Any idea about this behavior?
Regards
Prabodha