Copy link to clipboard
Copied
Hello there,
I am trying to create a pop up warning based on a validation calculation for a field.
I have this so far:
If(event.value(Hotel > (Lodging*nDays))) app.alert(“Amount exceeds the lodging per diem limit. Please select a justification for the higher lodging amount.”);
I'm getting a Syntax Error saying that I'm missing a before statement and I'm not sure how to move past this. I'm not a JavaScript person so I don't even know where to begin fixing this. Please help!
The basic code is this:
var v1 = Number(this.getField("Lodging").valueAsString);
var v2 = Number(this.getField("nDays").valueAsString);
if (event.value>(v1*v2)) {
app.alert("Amount exceeds the lodging per diem limit. Please select a justification for the higher lodging amount.");
}
Do you mean that if the alert is shown another field should be made required (and otherwide not)?
Use this:
if (event.value>(v1*v2)) {
app.alert("Amount exceeds the lodging per diem limit. Please select a justification for the higher lodging amount.");
this.getField("LodgingExceptionDropdown").required = true;
} else {
this.getField("LodgingExceptionDropdown").required = false;
}
Copy link to clipboard
Copied
Please explain what the validation should be first.
Copy link to clipboard
Copied
Oh, sorry about that. I tried to write it into the code up above (in the IF statement).
I want the Hotel field to validate against a calculated value that draws from two other fields. The value I am looking for it to validate against is [Lodging] multiplied byt [nDays]. If the amount entered into the Hotel field is greater than the value of "Lodging*nDays" then I want the pop up to appear.
Hopefully I'm using the right wording.
Copy link to clipboard
Copied
Do you also want to reject the value entered into the Hotel field in that scenario?
Copy link to clipboard
Copied
No. I do not want to reject the field. I would love to make another field (LodgingExceptionDropdown) required if possible but I didn't want to pile too much onto my question.
Thank you in advance try67!
Copy link to clipboard
Copied
The basic code is this:
var v1 = Number(this.getField("Lodging").valueAsString);
var v2 = Number(this.getField("nDays").valueAsString);
if (event.value>(v1*v2)) {
app.alert("Amount exceeds the lodging per diem limit. Please select a justification for the higher lodging amount.");
}
Do you mean that if the alert is shown another field should be made required (and otherwide not)?
Copy link to clipboard
Copied
Yes, that is what I mean. If the alert is shown, another field should be made required.
Copy link to clipboard
Copied
Use this:
if (event.value>(v1*v2)) {
app.alert("Amount exceeds the lodging per diem limit. Please select a justification for the higher lodging amount.");
this.getField("LodgingExceptionDropdown").required = true;
} else {
this.getField("LodgingExceptionDropdown").required = false;
}
Copy link to clipboard
Copied
Thank you! This worked perfectly! I always understand the code once I read it/see it but putting it together is not my strong point.