You can create If Statements to customize the data you want to display in a field. An If Statement is a statement that says “if” one condition exists, then do something.
For example:
= Type is System.String ? Type + " - " + Summary : "No activities found." ;
This statement says that if the Type field contains data, then display that data followed by "-" then the value in the Summary field. Otherwise, display the message “No activities found.”
To use an If Statement for a field in your report, create the If Statement as a calculated field (see Calculated Fields). Then select the calculated field in the DataField property.
Use the table below to help you construct If Statements.
If Statement Components
| Script Item | Meaning |
|---|---|
| = |
If (All If Statements start with this script item) |
| ? | Then |
| : | Otherwise |
| | | Or |
| + | Plus (used to concatenate fields) |
| == | Equals |
| && | And |
| “insert text here” |
Displays text For example: type “No Relationships” to display the text No Relationships |
| System.String | Field contains text (for text fields only) |
|
null or System.DBNull.Value |
Field is empty or leave the field blank |
| ( ) |
Used to “nest” if statements (include If Statements within other If Statements) This script item is used to ensure that complex calculations are in the right order. For example, the following If Statement would be interpreted differently if items weren’t nested in parentheses: = (Relationship is System.String) & (Person_Company_Indicator == "Person") ? "Location" : null; |
Writing If Statements takes practice, and at first will be a trial and error process. When creating new reports, it is best to copy and paste If Statements from existing reports and customize them as needed until you are comfortable writing them on your own.
InterAction Reports that Use If Statements
Many InterAction out-of-the-box reports use If Statements. You can refer to the following reports for examples.
InterAction Out-of-the-Box Reports that Use If Statements
| Report Name | If Statement |
|---|---|
| Contact List by Company |
The following If Statement is written for the calc_Group_Header_Label calculated field: =Company_Name is System.String ? Company_Name : "No Company" This statement says that if the Company_Name field contains data, then display this data in the Company_Name field. Otherwise, display the message “No Company.” An easier way to display these results is to create a calculated field using the DefaultValue and Formula properties. For details, see Using Calculated Fields to Display a Message if a Field Has No Value. |
| Known By - Who Knows Whom |
The following If Statement is written for the calc_Rel_Contact_Full_Name calculated field: =Related_Contacts_Name is System.String ? Related_Contacts_Name : "No information found"; This statement says that if the Related_Contacts_Name field contains data, then display that data in the Related_Contacts_Name field. Otherwise, display the message “No information found.” An easier way to display these results is to create a calculated field using the DefaultValue and Formula properties. For details, see Using Calculated Fields to Display a Message if a Field Has No Value. |
| Relationship List |
The following If Statement is written for the calc_Description calculated field: = Strength_Indicator == "Strong" ? "(" + Strength_Indicator + ") " + Relationship_Description : Relationship_Description; This statement says that if the data Strength_Indicator field has the value of Strong, then display the value of that field in parentheses along with the value in the Relationship_Description field. Otherwise, display the value in the in the Relationship_Description field. |