Hello
I am trying to stop the launch of a process in PPS170,PMS170 and DPS170 using validations and conditions using the H5 Script below:
var H5SampleCancelRequest = /** @class */ (function () {
function H5SampleCancelRequest(scriptArgs) {
this.controller = scriptArgs.controller;
this.log = scriptArgs.log;
this.elem = scriptArgs.elem;
this.args = scriptArgs.args;
if (ScriptUtil.version >= 2.0) {
this.miService = MIService;
}
else
{
this.miService = MIService.Current;
}
this.unsubscribeRequested = null;
this.unsubscribeRequesting = null;
this.unsubscribeRequestCompleted = null;
}
/* Script initialization function. */
H5SampleCancelRequest.Init = function (args) {
new H5SampleCancelRequest(args).run();
};
H5SampleCancelRequest.prototype.run = function () {
var _this = this;
this.unsubscribeRequesting = this.controller.Requesting.On(function (e) { _this.onRequesting(e); });
this.unsubscribeRequested = this.controller.Requested.On(function (e) { _this.onRequested(e); });
};
H5SampleCancelRequest.prototype.onRequesting = function (args) {
this.log.Info("onRequesting");
if (args.commandType === "LSTOPT" && args.commandValue === "11") {
args.cancel = true;
this.command = args.commandValue;
//Runs a bunch of APIs and conditions here
else
{
// proceed
args.cancel = false;
_this.controller.ListOption(_this.command);
}
}
// detach the request
if (false == args.cancel)
{
this.unsubscribeRequesting();
}
};
H5SampleCancelRequest.prototype.onRequested = function (args) {
this.log.Info("onRequested");
this.unsubscribeRequested();
this.unsubscribeRequesting();
};
return H5SampleCancelRequest;
}());
But when I do the action ctrl 11, my script does not work on first try.
When I go to my screen I have to scroll/refresh to look for my record then do ctrl 11, but the script does not work. However if I stop scrolling or refreshing and I do action ctrl 11 the script works on first try. The possible reason is that other events are being created while scrolling to look for records or refreshing the page.
Is there any way to resolve this to detach/unsubscribe to the event at the correct time?
Thank you