Validate Contact Email on Submission

This template uses a Form to enter a Contact email. When submitting the form, it tests if the contact already exists in Upvise by looking up the Contact email. If it exists, a warning alert is displayed. If not, the contact is created in Upvise with the input email.

Custom Fields: the Form also includes an input field which is used to update a Custom Field pre-defined for the Contact.

The Javascript code entered in the Execute on Submit field in the Form template Properties is as follows:

var email = F1.trim().toLowerCase();
var level = F2;
var count = Query.count(“Contacts.contacts”, “email=” + esc(email));
if (count > 0) App.alert(‘Email already exists!’);
else {
var id = Query.insert(“Contacts.contacts”, {name:email, email:email, creationdate: Date.now() });
CustomFields.values = CustomFields.loadValues();
CustomFields._update(“Contacts.contacts”, id, “F3”, level);
App.alert(‘Contact inserted!’);
}

return 1;

Note: a Custom Field must have been created for the Contacts app (in the web account Settings menu). In this example, the Custom Field has the ID “F3”, and it is a multiselect combo box type of field. The Options set in the Contact Custom Field must match the Form field (F2) Option values.

Download and Import the sample to the Templates section of the Forms app in your web account:

Validate Contact Email Exists

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s