Hi Sirs,
I ve been trying to create a validation for a field consisting of drop-down button/enumeration with 5 options. The goal is: if a user creates a new delivery template and leaves the field empty then an error message must pop-up once user tries to press the save button. So far i haven't been successful tho. here is the relevant part of the form.
the input:
<container>
<input required="true" xpath="@userPreference"/>
<static label="NB: Choose opt-out based on what category the email belongs to." type="help"/>
</container>
and, in the bottom part of the form file, the leave+check part
<leave name="leave">
<check expr="@userPreference!=''">
<error>test_test</error>
</check>
</leave>
</form>
What am i missing?
Cheers
Views
Replies
Total Likes
Hi @PabloNeruda,
In your <leave> tag you can print the value of the "@userPreference" xpath to double check what value it gets assigned:
<leave>
<msgBox translatedExpr="'user preference'+[@userPreference]"/>
<check expr="@userPreference!=''">
<error>test_test</error>
</check>
</leave>
</form>
Since you are using a dropdown, could be that the default value of this xpath is not blank if there is no selection made by the user.
Let me know if that helped.
BR,
Ishan
Hello @isahore ,
thanks for your reply.
I have added the msgbox row but it didnt help, i still can either leave the field empty or choose among the 5 options, i can save the form with no problem
<leave name="leave">
<msgBox translatedExpr="'user preference'+[@userPreference]"/>
<check expr="@userPreference!=''">
<error>test_test</error>
</check>
</leave>
</form>
I wonder if perhaps in the form view is not possible to create a error message? coz in the delivery properties it is no problem to create it (see screenshot) while in the form view no success so far
Have you ever managed to create an error message in the form view?
Views
Replies
Total Likes
@PabloNeruda, are you able to get the value of your selection displayed on message box pop-up? What do you see there?
Error message logic works for all input forms, OOTB and custom, equally. Maybe something else in your form is not letting the leave tag execute properly. Could you share more details, more of the form code - for example?
BR,
Ishan
Views
Replies
Total Likes
Hi, I checked your code in my local. Works fine for me. Looks like you have some other issue with your form as per your attachment. Click on the 'Details' button in your error message which says - 'The graphical component "Product*" has generated an error. That would help to identify the issue in your form.
Working code:
nms:newDelivery input form:
<leave name="leave">
<msgBox translatedExpr="'delivery label='+[@label]"/>
<check expr="@label!='test'">
<error>It is not possible to create a delivery with label 'test'</error>
</check>
</leave>
I can view the msgBox as below:
Error message:
Views
Replies
Total Likes
Hi @isahore and @somasundaram_h, thank you for taking the time to reply.
The error message which i shared previously is from the delivery properties tab (nms:delivery), where the error message works just fine (as i showed in the screenshot posted in my previous post). in that part, which works, i have this input:
<input label="Produkt* " required="true" xpath="@produktomrade">
<enter name="onChange">
<set expr="1" xpath="/ignored/@deliveryCodeParams"/>
</enter>
</input>
and at the bottom the leave part
<container>
<input required="true" xpath="@userPreference"/>
<static label="OBS: Choose correct opt-out category"
type="help"/>
</container>
and in the bottom
<leave name="leave">
<msgBox translatedExpr="'user preference'+[@userPreference]"/>
<check expr="@userPreference!=''">
<error>test_test</error>
</check>
</leave>
</form>
when i then create a delivery and the opt-out field is blank it still allows me to save with no error message. i ll attach a few screenshots for better clarity.
Thank you
Views
Replies
Total Likes
Views
Likes
Replies