Hi, I'm facing an issue about H5 script. I need to check and validate user input by making an API call (EXPORTMI) but when I do that, the script continues to execute and validate the screen before the api call is returned.
The user can validate the screen so my controls are pointless. Do you have any idea about how to make my code wait for the returned data ? I use .then(response => {...}); syntax but it doesn't seem to work. Thank you
Here's my code :
const getValeurBac = this.initMiRequest("EXPORTMI", "Select", { QERY: "UACONO from MTEFLA where UACONO = 600 and UACFMF = '"+vStr_Bac+"' and UACFMA = '" + vStr_TypeBac + "'" });
const getValeurBacPromise = this.miService.executeRequest(getValeurBac);
Promise.all([getValeurBacPromise]).then(response => {
if (response[0].items.length == 0){
args.cancel = true;
setTimeout(() => {
this.showDialog("La valeur du type de bac n'existe pas", "TextBoxTypeBac");
}, 0);
} else {
/* les 3 premiers caractères du n° de bac doivent être égaux aux 3 derniers caractères du type de bac */
if (vInt_NoBac.substring(0, 3) != vStr_TypeBac.substring(vStr_TypeBac.length - 3)) {
args.cancel = true;
setTimeout(() => {
this.showDialog("Les 3 premiers chiffres du N° du bac et les 3 derniers chiffres du type de bac ne correspondent pas", "TextBoxNoBac");
}, 0);
} else {
/* Mémo valeur testé */
this.vBoo_ControleFait = true;
}
}
}).catch((response: IMIResponse) => {
this.log.Error(response.errorMessage);
});