Question

Custom Field Validation and Error Checking

  • 13 June 2023
  • 3 replies
  • 404 views

Badge

Hello,

Is there anyway we can validate/error check/add logic to custom fields prior to the user submitting a service request form?  Here are some examples:

If we have a date field, we need to be able to see if the date has occurred in the past and if so, alert the user to change the date to at least be the current day.  

If we have a number/decimal field, but say only want the value to be less than 100, to be able to add logic to the field for < 100.

If we have a text field where we are asking for an email address, to be able to validate the address and make sure that not only there’s an @ symbol, but where we can also validate the domain.  In our case, we would only want the email domain of our company.

Thanks


3 replies

Userlevel 4
Badge +4

Hi @jhanna,

 

With the Business Rules for Forms you can create rules for a service item, do a check for conditions in a field and set one or more actions.

  1. regarding your date validation, the condition could be:

Ticket field - <date field>  is not “at least 1 day ago”:

or even better:

Ticket field - < date field> less than or equal to “Select from Placeholder”- “System” -  “Current Date” (the check is only on the date part, not a combination of date and time):

 

The action in the rule is in this case a “Validate form on Submission” text, that will be shown in the top right corner of the page when an incorrect value is entered while trying to Place the Request.

 

 

  1. To validate the input of a number, can be made in a different Business Rule as well.

The condition in here is item Field - <field name> is less than 100

Action: similar text as shown with the date field.

 

  1. Validation of an email address can't just be done out of the box.
    1. Why not using values from a data source?
    2. Or use a Custom Object (if available) to show a predefined list with users, this will also reduce the chance for spelling mistakes.
    3. In theory with a little piece of Java Script code a validation of the entry should be possible as well.

 

Let me know your thoughts.

 

Kind regards,

 

Rutger Bockholts

Freshworks

Badge

Hi @Rutger Bockholts,

Yes, thank you!  I believe the business rules will work for most of the fields.  I’ll play around with it a bit.

For the email address, I have to use a custom object (All Users) because I want to send off an approval email, but I need the custom object to be dynamic with logic included for it to work. Using “All Users” will meet the dynamic part.

Wouldn’t the condition below theoretically work though for email validation?
 

 

Badge

@Rutger Bockholts,

I spoke too soon.  If I’m using a custom object in the form, I am limited with the conditions I can select, and I can’t enter a domain if I select “includes”.  It’s looking for a specific entry in the custom object.

 

If I use just the text field, then I’m able to select “ends with” and add @domain.com

 

Looks like the trade off is having the user enter an email address, then I can verify that at least the domain is correct.

Reply