Applies to: NITRO activated sites in SharePoint online and On-premises (SharePoint Server Subscription Edition)
Define NITRO Variables in NITRO Forms
To define the variables in NITRO forms,
Go to the list -> List Settings -> Crow Canyon NITRO Forms -> Variables -> Define the variables as shown below:
Work with variables in different places in NITRO forms
Line/HTML Control:
Syntax to use variable value in Line/HTML control: %%Variable##Value%%
To show dynamic column placeholder value in Line/HTML control, enable “Dynamic placeholder evaluation” and use column placeholder syntax as shown below:
%%[Column Internal Name]%%
This will be useful to show dynamic column values in Line/HTML control in the new form.
Form Event Actions:
Fetch List Items:
Syntax to use variable value in “Fetch List Item” action: %%Variable##Value%%
Set Variable values:
Use this action to update the variable values.
We can set the column placeholders, functions, variables, and Fetch Items for the variables.
Column Placeholder:
To save the column placeholder value in a variable, select the column from “Define Variable Value Expression” and click “Add Placeholder to Value”
Syntax: [Column Display Name|Column Internal Name]
Ex: Save the Category lookup column value in a variable: [Category|Category]
Functions:
Use the functions listed in “Define Variable Value Expression” as per the requirement
Ex: To sum values from two columns, use “Add” function $add([Total Amount|TotalAmount],[Tax Amount|TaxAmount])
Variables:
To copy the value from a variable, use variables in “Define Variable Value Expression”
Syntax: Variable##Value
Ex: VarRequester##Value
Fetch Items:
All the configured fetch item actions will be shown here. Below are the sample use cases for using variables with item and item collection.
- Item:
In this example, configured a fetch item action to save “Budget” column value in a variable from “Departments” list based on the “Department” lookup selection on the form.
Action 1: Configure fetch item action to get the department based on the selected “Department” column value
Action 2: Configure set variable value action to update the variable value with “Budget” column value from selected Department.
Variable value expression:
CCSQLGetDept##[Budget|Budget]
2. Items:
In this example, configured a fetch item action to get all line items and update a variable with sum of total cost of all line items.
Action 1: Configure fetch item action to get all the related line items from Purchase Items list
Action 2: Configure set variable action to update a variable with sum of total cost of all line items.
Variable value expression:
CCSQLGetILinetems##$sum([Total Cost|TotalCost])
Update Form Controls:
Syntax to use variable value in Update Form Control action:
Variable##Value
Condition Builder control:
Syntax to use variable value in condition control in permissions, validations, and form event actions:
Variable##Value
Custom Script:
Get Variable Value:
Syntax to get value from a variable using custom script in NITRO Forms:
Syntax: window.ccs_g_FormUI.GetVariableValuebyName(“Variable Name”)
Ex: window.ccs_g_FormUI.GetVariableValuebyName(“VarRequestStatus”)
OutPut: Sometimes we get output in string format and sometimes in Object format, we need to use the output result as per as per our requirement in the custom script.
Set Variable Value:
Syntax to update variable value using custom script in NITRO Forms:
Syntax: window.ccs_g_FormUI.SetVariableValuebyName(“Variable Name”,Variable Value)
Ex: window.ccs_g_FormUI.SetVariableValuebyName(“VarRequestStatus”,”Closed”)
Above functions can be used in custom java script section in below actions in Form Event Actions:
- Execute Script
- Update Form Controls
- Set Variable Value
Use case:
Concatenate “First Name” and “Last Name” on column value change and update it in “Full Name” column.
In this sample use case, we have used variables and form event actions in NITRO forms to achieve this.
Steps:
- Define variables
- Configure Form Event Actions
In this sample use cases, we have covered output of a variable in both String and Object format
- Get variable value as Object
- Get variable value as String
Detailed Steps:
Get variable value as Object
1.Define variables:
Define below variables in NITRO Forms.
- VarFirstName
- VarLastName
2. Configure Form Event Actions:
Configure form event action on “First Name” and “Last Name” column value change as shown below:
Action 1: Set variable value
Configure set variable action as shown below:
VarFirstName
VarLastName:
Action 2: Update Full Name
Script:
var ObjFirstName = window.ccs_g_FormUI.GetVariableValuebyName(“VarFirstName”);
var ObjLastName = window.ccs_g_FormUI.GetVariableValuebyName(“VarLastName”);
var FirstName = “”;
var LastName = “”;
if (ObjFirstName && ObjFirstName.Computed){
FirstName = ObjFirstName.Computed.Display;
}
if (ObjLastName && ObjLastName.Computed){
LastName = ObjLastName.Computed.Display;
}
if(FirstName && LastName){
return FirstName +” “+ LastName.ComputedValue;
}
else if(FirstName)
{
return FirstName.ComputedValue;
}
else if (LastName)
{
return LastName.ComputedValue;
}
else
{
return “”;
}
Get variable value as string
1.Define variables:
Define below variables in NITRO Forms.
- VarFirstName
- VarLastName
2. Configure Form Event Actions:
Configure form event action on “First Name” and “Last Name” column value change as shown below:
Action 1: Execute Script
Configure execute script action to update the variable values using Set variable function.
Script:
var FirstName = _ccs_FormUI.fetchColumnValueUI(“FirstName”);
var LastName = _ccs_FormUI.fetchColumnValueUI(“LastName”);
window.ccs_g_FormUI.SetVariableValuebyName (“VarFirstName”, FirstName);
window.ccs_g_FormUI.SetVariableValuebyName (“VarLastName”, LastName);
functionCallback();
Action 2: Update Form Control
Configure update form control action to get the value from variables using Get variable function and update the “Full Name”.
Script:
var FirstName = window.ccs_g_FormUI.GetVariableValuebyName (“VarFirstName”);
var LastName = window.ccs_g_FormUI.GetVariableValuebyName (“VarLastName”);
if(FirstName && LastName){
return FirstName+” “+LastName;
}
else if(FirstName)
{
return FirstName;
}
else if (LastName)
{
return LastName;
}
else
{
return “”;
}