Handling the Data in Multi Select fields in Validate Rules and Table Level Scripts

2 minute read time.

This will look at the behaviour of the Values collection. For a more complete discussion see the article The Values() Collection.

Imagine a new field called pers_type has been added to the person table and included to the screen personboxlong. The field pers_type is a multiselect and can contain the following values: User, Influencer, Gatekeeper, BudgetHolder, Advocate, DecisionMaker.

How can the return values be seen in either a Validate rule or a Table Level script?

Validate Rules and Multi Select

The Validate rule needs to be added to a field within the personboxlong screen. There are two collections that can be used to obtain the submitted values of a field. These are Values() and FormValues(). I used three scenarios to illustrate the data returned.

  1. The user selected only the data value 'Influencer' before submitting.
  2. The user selected the data values 'Influencer' and 'Gatekeeper' before submitting.
  3. The user selected all possible values before submitting.

Using Values()

The code below is a simple test to show the string returned

Valid = false;
ErrorStr = Values("pers_type");

Results for Values() in Validate Script

  1. "Influencer" returned on screen.
  2. "Influencer" returned on screen.
  3. "Influencer" returned on screen.

Using FormValues()

The code below is a simple test to show the string returned

Valid = false;
ErrorStr = FormValues("pers_type");

Results for FormValues() in Validate Script

  1. "Influencer" returned on screen.
  2. "Influencer,GateKeeper" returned on screen.
  3. "User,Influencer,Gatekeeper,BudgetHolder,Advocate,DecisionMaker" returned on screen.

Note: To allow you to return a comma delimited list of values submitted from a screen within a Validate rule, you must use FormValues().

Table Level Scripts and Multi Select

The Validate rule within the screen was removed and an UpdateRecord event function within a table level script defined against the person table was then tested.

The same test scenarios as above were used.

Using Values()

The code below is a simple test to show the string returned

function UpdateRecord()
{
Valid = false;
ErrorStr = Values("pers_type");
}

Results for Values() in Table Level Script

  1. ",Influencer," returned on screen.
  2. ",Influencer,Gatekeeper," returned on screen.
  3. ",User,Influencer,Gatekeeper,BudgetHolder,Advocate,DecisionMaker," returned on screen.

Note: There is a comma prefix and suffix added to the returned string.

Using FormValues()

The code below is a simple test to show the string returned

function UpdateRecord()
{
Valid = false;
ErrorStr = FormValues("pers_type");
}

Results for FormValues() in Table Level Script

  1. "Influencer" returned on screen.
  2. "Influencer,GateKeeper" returned on screen.
  3. "User,Influencer,Gatekeeper,BudgetHolder,Advocate,DecisionMaker" returned on screen.

Note: There is NO comma prefix and suffix added to the returned string.

Note: To allow you to return a comma delimited list of values submitted from a screen within a Table Level Script, you should use FormValues() as it provides an easier to parse result.