Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this chapter we will add validation to the data users type into forms. To do this, we need to add custom actions to insert and update actions. Adding custom actions is an important stepsstep, and allows you to do many things with actions beyond validating data. When adding custom actions to update and insert actions, there are a couple of crucial things to remember:

...

Similarly, try updating a record, inserting an invalid character to the telephone number. Your validation should prevent you from saving this update.

Validate business contacts have business name

Next we'll add some additional validation to check that business contacts have a business name set:

Widget Connector
width900
urlhttps://www.youtube.com/watch?v=KCOe5XlmCCA&list=PLbPt6SI1Zhb_n3lXboTC_Qzq0Kg2x8LtT&index=9
height500

Add this validation to your app. To recap the steps in the video:

  • Open details for the action Validate Contact - you can either open the stream configuration form for Contacts, and find the list of actions; or click on the Add or Update button, and from the button configuration form, follow the quick link to the action details
  • Add a condition to the validation expression to check that for business contacts, the business name is set; make sure you remember you put a comma after the if() statement you already have in your expression, then add:
Code Block
if ( (_form.ContactType == "Business") && (isEmpty(_form.BusinessName)),
    error("Business name must be set for business contacts")
)
  • Save changes to your action

Go into App Mode. Check that the error is shown when users forget to enter a business name for a business contact.

Panel
Next chapter: TODO 8. Setting values in actions