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 | ||||||
---|---|---|---|---|---|---|
|
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 forContacts
, and find the list of actions; or click on theAdd
orUpdate
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 |