Below are simple IF statements that can be utilised within the system. In all of the examples below, please substitute the 'target.criteria' or 'target.field' with the criteria/target field respectively, you would like to reference.
If the criteria is set to pass
<% if target.criteria_driving_license.responses.recent.is_compliant|yesno:'Pass,Fail' = "Pass" %>
{content}
<% endif %>
The if statement above, will output the content specified as long as the criteria is completed { yesno:'Pass,Fail' = "Pass" }.
To determine number of responses in a DRAA2 references
<% if target.criteria_draa2_online_doc.responses.recent.components.all|length %>
{content}
<% endif %>
The target enters their references when using the response type Date and range Activity 2. This IF returns the number of references entered. This piece of code can be directly copied into your document.
To call upon certain reference entries
<% if target.criteria_draa2_online_doc.responses.recent.components.entry_1.activity_detail %>
{content}
<% endif %>
When dealing with the references the target has provided via the Date and Range Activity 2, the IF statement can reference each individual one just by changing the 'entry_1' number. This piece of code can be directly copied into your document.
To extract a certain record or type(activity) of record within DRAA2 references provided
<% for reference in target.criteria_employment_history.responses.recent.components.all %>
<% if reference.activity_type == 'Personal Reference' %>
{content}
<<reference.referee_data.field_firstname>>
<% endif %>
<% endfor %>
The FOR statement looks through all the references that have been provided through the DRAA2 response type in the criteria 'employment history'. IF the activity type within the DRAA2 has the activity type 'Personal Reference', then 'reference.referee_data.field_firstname' outputs the first name the target entered when filling out the information of the referee. The statement will continue to output all of the first names until it reaches the end.
Notice how there is the use of 'reference' in the FOR statement and the IF statement content, this is just an alias used to connect the merge field with the for statement. This can be changed to anything.
To reference if target field has been populated with a response
<% if target.field_description %>
{content}
<% endif %>
The IF statement is in relation to a target field. This simply checks to see if the field specified has been populated with a response, if yes it displays the content if not, it doesn't.
To reference if target field is NOT populated with a response
<% if not target.field_description %>
{content}
<% endif %>
The IF statement is in relation to a target field. This simply checks to see if the field specified is not populated with a response, if it's not it will display the contents and if it is, it will not display the content.
To accomodate multiple statements
<% if target.field_description %>
{content}
<% else %> or <%elif target.field_description_2 %>
{content}
<% endif %>
To use multiple IF statements at once, the statement above can be used. If there is a boolean option (true/false) 'else' is ideal, however if there are more than two conditions, then 'else if' and state the second condition.
OR Operator
Alternatively, if the value returned needs to meet at least one of the conditions listed the operator 'or' is used.
<% if target.field_answer_one == "Yes" or target.field_answer_two == "Yes" %>
{content}
<% endif %>
So if either of the conditions are met, the if statement will output the content.
AND Operator
<% if target.field_answer_one == "Yes" and target.field_answer_two == "Yes" %>
{content}
<% endif %>
Similarly, the 'and' operator, will output the content if all the conditions are met.
Comments
0 comments
Please sign in to leave a comment.