Copy link to clipboard
Copied
Hi there, i am testing some fileds in an XFA form and into a presign event using Livecycle ES2. I have a code like this:
//Check the Type of Request if selected
if ((F.P1.TypeOfRequest.InitCB.rawValue + F.P1.TypeOfRequest.ModCB.rawValue + F.P1.TypeOfRequest.DACB.rawValue + F.P1.TypeOfRequest.IDCB.rawValue) == 0) {
xfa.host.messageBox("The Type of Request is not selected. Please check it.");
xfa.host.setFocus(F.P1.TypeOfRequest.InitCB); //Fuonziona, anche l'eventuale scroll
xfa.event.cancelAction = 1;
}
//Check the presence of the UserID when the US Check Box is selected
//if (F.P1.CitizenShip.USCB.rawValue == 1) {
if (F.P1.TypeOfRequest.UserID.isNull || (F.P1.TypeOfRequest.UserID.rawValue.length < 10)){
xfa.host.messageBox("The UserID is not correct or is not filled up. Please check it.");
xfa.host.setFocus(F.P1.TypeOfRequest.UserID); //Fuonziona, anche l'eventuale scroll
xfa.event.cancelAction = 1;
}
//}
.
.
.
and so on.
I would like to escape from the presign event once one of the if is true like a goto statement:
//Check the Type of Request if selected
if ((F.P1.TypeOfRequest.InitCB.rawValue + F.P1.TypeOfRequest.ModCB.rawValue + F.P1.TypeOfRequest.DACB.rawValue + F.P1.TypeOfRequest.IDCB.rawValue) == 0) {
xfa.host.messageBox("The Type of Request is not selected. Please check it.");
xfa.host.setFocus(F.P1.TypeOfRequest.InitCB); //Fuonziona, anche l'eventuale scroll
xfa.event.cancelAction = 1;
// " goto TheEndProcedure " //
}
Is there the possibility to do that? Thank You.
Copy link to clipboard
Copied
It's pretty simple. Read this: https://www.w3schools.com/js/js_functions.asp
Basically you can do it like this:
function myFunction() {
// rest of code goes here;
}
myFunction();
And when you want to stop the code you add this command into it:
return;
Copy link to clipboard
Copied
This is just standard JavaScript. One way you can do this is with an extra variable:
var done = false;
if (firstCondition) {
// do something
done = true;
}
else if (secondCondition) {
// do something else
done = true;
}
if (!done && thirdCondition) {
// ...
done = true;
}
// and so on
Copy link to clipboard
Copied
Put the whole code in a function (could even be an anonymous one) and call return when you want to exit it.
Copy link to clipboard
Copied
Try67,
i am not so skilled and i do not know how to create my own function.
Please tell me how and where to create a function. Thank You.
Copy link to clipboard
Copied
It's pretty simple. Read this: https://www.w3schools.com/js/js_functions.asp
Basically you can do it like this:
function myFunction() {
// rest of code goes here;
}
myFunction();
And when you want to stop the code you add this command into it:
return;
Copy link to clipboard
Copied
Try67,
Thank You it works perfect. I want thank also Mr. Karl Heinz Kremer for his solution!

