Conditional insertion in emails and phone participants introductory text
Sample management fields, project properties, and blocks of text can be conditionally inserted into the email body and the Phone Participants introductory text. Conditional insertion is useful if some participants require different information when participating in the survey. For example, when phoning respondents, the introductory text might be different for an inbound call than for an outbound call.
Conditional insertion is implemented through evaluation of data model expressions. This supports conditional inclusion and exclusion of blocks of texts and conditional formatting.
For example, this command includes different text according to the number of times that the participant has been contacted, by testing the ContactCount value:
{If:{[Sample field:ContactCount] = 0}}
Thank you for agreeing to take part in this research project.
{Else}
Thank you for your continuing participation in this research project.
{End If}
Tags for conditional insertion
In the email body or introductory text, surround the conditional text by using these markers:
{If:{<data-model-expression>}}
Includes the text that is between this marker and either the next conditional insertion marker or the end of the introduction only if the expression evaluates to True.
{ElseIf:{<data-model-expression>}}
Includes the text that is between this marker and either the next conditional insertion marker or the end of the introduction only if the expression evaluates to True and the previous conditional expressions evaluated to False.
{Else}
Includes the text that is between this marker and either the next conditional insertion marker or the end of the introduction only if the previous conditional expressions evaluated to False.
{End If}
Marks the end of a group of conditional statements.
{Eval:{<data-model-expression>}}
Include the text that results from the evaluation of the expression.
Rules for conditional insertion tags
▪Tags are case-insensitive. For example, If:, IF:, and if: are the same.
▪Any existing insert tag can be used in the data model expression. It must be enclosed in brackets, for example: [Sample field:Name]
▪Strings used in the expression must be enclosed in double quotation marks, for example, "Region1"
▪If the inserted field does not exist, it is not replaced. For example:
If the text includes {Sample field:FirstName} and the FirstName field does not exist, {Sample field:FirstName} is displayed.
If [Sample field:FirstName]is used in an expression and FirstName does not exist, its value is {Sample field:FirstName}, which might an unexpected result.
▪If the expression can not be evaluated (for example, a divide by zero error occurs), an error is displayed to the email recipient or interviewer.
▪The result of If and ElseIf tags is a Boolean value.
▪The result of the Eval tag is a text value.
▪Any conversion of values to text values uses the locale of the email or introduction text language. This ensures, for example, that date values are formatted appropriately.
▪Any linefeed character that immediately follows an If, ElseIf, Else, or End If tag is removed. This means, for example, that you can put the If tag on its own line to make it easier to read the script, but the linefeed character is not included in the output text.
▪Brace characters, { and }, can generally be used in the introductory text as needed.
To include { as a character rather than the start of a tag, use {{. For example:
{{If the participant hesitates then code as Refused}
displays as:
{If the participant hesitates then code as Refused}
Identifying call types
When creating introductory text for phone interviewing, it might be useful to insert different text for inbound calls or when a call has been transferred. To differentiate between types of calls, use the InOut sample field:
Call type
|
InOut value
|
Outbound
|
0
|
Inbound known
|
1
|
Inbound unknown
|
2
|
Inbound withheld
|
3
|
If a call has been transferred, the IsTransfer Interview property is set to True. For example, to identify a transferred call, you can use a construct like this:
{If:{[Interview property:IsTransfer] = True}}
Example of using conditional insertion
This example formats a sample field value. It converts the appointment time (which is stored as UTC) into the time zone of the respondent.
"You previously asked us to call you back at {Eval:{UTCToLocalTime([Sample field:AppointmentTime], [Sample field:TimeZone])}} "
This example includes different inline text:
"Can you confirm {If:{[Sample field:Gender] = "Female"}}her{ElseIf:{[Sample field:Gender] = "Male"}his{Else}their{End If} date of birth?"
This example is an alternative method of including different inline text:
"Can you confirm {Eval:{IIf([Sample field:Gender] = "Female", "her", IIf([Sample field:Gender] = "Male", "his", "their")}} date of birth?"
See also