Person Validation

Your church may optionally decide to require certain fields be completed for newly created records and/or for records that are edited. For example, if your church would like to require that First Name, Last Name, Address, and Date of Birth be required for all newly created records, no new records will be able to be added to your TouchPoint database without information in those fields.

Records created via Web Check-In; through the Mobile App (coming soon); or by using the Skip Search / Add New or (after searching) by Add New Family (through an Involvement, a Meeting, Contribution Entry, etc.) will require the specified fields be completed. Online Registrations, Online Giving, and donors imported from an outside integration do not obey the settings. When creating the new people record, an asterisk (*) will appear alongside the required fields.

Configure the Required Fields

Step 1
Go to Administration > Setup > Special Content and select the Python Scripts tab.
Step 2
From there, select the PersonValidation script.
Step 3

Modify the script to suit your church’s needs. In addition to requiring fields be complete upon new record creation and/or people record editing, you may also add an error message to let the user know what is required for a particular field. Press the blue Save Python Script button at the bottom of the file.

Note

You may configure what is required on Mobile separately from what is required on Web. Additionally, you may configure what is required differently for various contexts. For example, you may relax some of the required fields for contribution entry only.

Step 4
Enable an Administrative Setting by navigating to Administration > Setup > Settings > System > Administration and select toggle the UsePersonValidationScript to True.
Step 5
Still in the System > Administration tab of the Administrative Settings, add the desired information in the Value field for AddPersonRequiredFields (to require fields on new record creation) and/or EditPersonRequiredFields (to require fields while editing people records). Enter the values such as FirstName, LastName, CellPhone, HomePhone, EmailAddress, DOB, or AddressLineOne separated by commas.
https://i.tpsdb.com/Hayley-PersonValidation.png

Required Settings (Note that other settings are between them in the database.)

Person Validation Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import json

# Common options for context include "api", "checkin", "contribution", "mobile", "people", "register", "onlinereg"
# Contexts for "upload", "pushpay", "python", or anything else will NOT use this script
context = model.Data.context

# This is the person being edited or added
person = model.Data.person

# If this person is being edited, these are the changes
changes = model.Data.changes

errors = {}
labels = { "FirstName": "First name", "LastName": "Last name", "CellPhone": "Cell phone", "HomePhone": "Home phone", "EmailAddress": "Email", "DOB": "Birthday", "AddressLineOne": "Address" }

def missing(value):
    return value == None or not len(value)

# Use this function to indicate a required field
def require(field, value=""):
    if missing(value):
        errors[field] = labels[field] + " is required"

# Begin defining your rules here

# You can add errors to prevent the save operation of the record. These will be displayed to the user
# e.g. errors["LastName"] = "Last name must be longer than 2 characters"

# On mobile, users will enter and save one field at a time
if context == "mobile" and changes:
    for change in changes:
        if change.Field in ["FirstName", "LastName", "CellPhone", "HomePhone", "EmailAddress", "DOB", "AddressLineOne"]:
            require(change.Field, change.After)
# Web context
else:
    require ("FirstName", person.FirstName)
    require ("LastName", person.LastName)

    if missing(person.AddressLineOne) and missing(person.Family.AddressLineOne):
        require("AddressLineOne")

    if missing(person.CellPhone) and missing(person.Family.HomePhone):
        require("CellPhone")

    require("EmailAddress", person.EmailAddress)
    require("DOB", person.DOB)

print(json.dumps({"Errors": errors, "Valid": len(errors) == 0}))


Latest Update 06/07/2021

Article Created