Forums

Best way to show error message when a field fetched via the API is empty

DrSmith69 28 May, 2018
Hi All,

I have a form which makes a connection to my web services to fetch details based on a parameter,

Based on the parameter passed one field will always have data i.e. last name.

how can I stop the form from progressing to page 2 if the field is blank after fetching from page 1.

My form works as follows:

1. page 1 - client enters parameter and submits
2. page 2 - populates based on parameter entered on page 1

If surname field is empty on page 2 I need a message to pop up with invalid parameter redirecting them back to page 1
GreyHead 28 May, 2018
Hi DrSmith69,

You can use an Event Switcher to contain the code to run the web service check. Set it up with one event e.g. not_found and if, after the check the info is not found then return 'not_found'; and in the not_found Event add a Message and an Event Loop action.

Bob
DrSmith69 28 May, 2018
Hi Bob,

Many Thanks - Will look into using the event switcher and revert back,

Looking at the event switcher though it requires a certain output where I can identify what to do after that,

In essence, if i do the following it will work?

1. Set a placeholder in the lastname box
2. create the event switcher with one single switch equal to the placeholder above.
3. set the message and loop part of the event switcher, leave the rest of the fields as is, they will run as normal if the placeholder is overridden?

Many Thanks,
DrSmith69 28 May, 2018
Hi Bob,

Ok so I have tested my theory and it should work but I cannot get the message to pop up:

1. Set the value to D3H0 in last_name
2. make the event switcher D3H0 set to that {data:last_name}
3. Add a error message in the switch

Please see the pictures - The message is not popping up - am I maybe putting the event switcher in the wrong place? I tried it in between each of the other events and still nothing




DrSmith69 29 May, 2018
Answer
Got this working using a validate fields security setting, left the success blank, put a message and redirect in fail to go back to the load page.
This topic is locked and no more replies can be posted.