You are viewing limited content. For full access, please sign in.

Question

Question

Set up a timeout error message if data lookup is not found

asked on June 13, 2017

Hi All,

 

We have some forms where we are using data lookups in the forms gui to retrieve a field value and then go on to populate other fields. This works 90% of the time, until a user may enter incorrect data that can't be found in the lookup table.

Is it possible to set a time value (eg 30 secs) so if no data is found or one of the fields isnt populated, an error will display on screen for the user (such as We could not find that record, please check and enter again).

 

cheers

0 0

Answer

SELECTED ANSWER
replied on June 15, 2017

Not sure how the spinner was setup, but calling $('.spinner').hide() should hide it:

$(document).on('lookupcomplete', function(event){
  if (event.triggerId == 'Field1') {
    $('.spinner').hide();
   //other actions
  }
})

 

1 0

Replies

replied on June 14, 2017

Instead of use timeout, you can listen for event 'lookupcomplete' which is triggered on lookup finish. This event is available for Forms 10.2 and above.

The script could be like this (Field1 is lookup trigger field while Field2 is target field):


  $(document).on('lookupcomplete', function(event){
    if (event.triggerId == 'Field1') {
      if ($('#Field2').val()) {
        $('#Field1').parsley().removeError('customError');
        }
      else {
        $('#Field1').parsley().addError('customError', { message: 'We could not find that record, please check and enter again.'});
      }
    }
  })

 

1 0
replied on June 15, 2017

That is fantastic Rui, thank you.

We are using a spinner (loading gif) that I have field rules set up that temporarily displays until the Target field (Field2) is populated. Our users would like take this one step further and hide the spinner (class = spinner) at the same time when the error message is displayed. Are you able to please help on how to aply that to your existing code above?

 

cheers

 

0 0
SELECTED ANSWER
replied on June 15, 2017

Not sure how the spinner was setup, but calling $('.spinner').hide() should hide it:

$(document).on('lookupcomplete', function(event){
  if (event.triggerId == 'Field1') {
    $('.spinner').hide();
   //other actions
  }
})

 

1 0
replied on June 15, 2017

Great, thanks again yes

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.