Field Visibility Examples

You can set conditions on each field, so you can determine whether the field is shown or not.

Where do you set it?

Open a field:

Click on tab 'advanced'

This manual explains how to set the conditions via Javascript, so always choose this option in the dropdown.

A condition always depends on the chosen value(s) in another field. You can call up all fields via the last dropdown:

Please note, this list can be very long. The questions are grouped by tab, and then alphabetically.

Once you have chosen a field, this will appear:

Choose 'Value' each time to place the condition. The Values ​​are only numeric if necessary, so the label value can be freely adjusted.

Click ADD to add the reference in the 'Visibility' field.

It will say this: #REPLACE-PARTVALUE-aanvraag_type||Value#

Possible conditions

Value = X

return #REPLACE-PARTVALUE-<internal label>||Value#

=== 'X';

Example

return #REPLACE-PARTVALUE-aanvraag_type||Value#

=== '4';

Value is different from X

return #REPLACE-PARTVALUE-<internal label>||Value#

!== 'X';

Example return #REPLACE-PARTVALUE-aanvraag_type||Value#

!== '9';

Value equals to X, Y or Z

var <internal_label> = #REPLACE-PARTVALUE-<internal_label>||Value#;

if (<internal_label> == X || <internal_label> == Y || <internal_label> == Z) return true

else return false

Explanation So we first create a variable, and use it in the conditions.

'OR' conditions are put together via ||.

Example:

var aanvraag_type = #REPLACE-PARTVALUE-aanvraag_type||Value#;

if (aanvraag_type == 1 || aanvraag_type == 2 || aanvraag_type == 4) return true

else return false

Value is TRUE (Yes) (only valid for Yes/No field)

return #REPLACE-PARTVALUE-<internal_label>||# === "true"

Value is FALSE (No) (only valid for Yes/No field)

return #REPLACE-PARTVALUE-<internal_label>||# === "false"

Combine AND & OR

example:

([aanvraag_type]='4' or [aanvraag_type]='2') and [st_opdrg_int_yn]='1'

This is how it is built:

var <internal_label1> = #REPLACE-PARTVALUE-<internal_label1>||Value#;

var <internal_label2> = #REPLACE-PARTVALUE-<internal_label2>#;

if ((<internal_label1> == 2 || <internal_label1> == 4) && (<internal_label2> == true)) return true

else return false

Multiple AND conditions

We want to make this: [aanvraag_type]='4' and [aanvraag_chemsubst_yn]='1' and [st_opdrg_int_yn]='1'

var <internal_label1> = #REPLACE-PARTVALUE-<internal_label1>||Value#;

var <internal_label2> = #REPLACE-PARTVALUE-<internal_label2>#;

var <internal_label3> = #REPLACE-PARTVALUE-<internal_label3>#;

if ((<internal_label1> == 4) && (<internal_label2> == true) && (<internal_label3> == true )) return true

else return false

----Example (looking at 2 yes/no - fields)---

var MEDDEV_CE_markering_scope_YN = #REPLACE-PARTVALUE-MEDDEV_CE_markering_scope_YN||#;

var MEDDEV_andere_indicatie = #REPLACE-PARTVALUE-MEDDEV_andere_indicatie||#;

if ((MEDDEV_CE_markering_scope_YN == "true") && (MEDDEV_andere_indicatie == "true")) return true

else return false

If anything is picked in another field, show this field:

return (#REPLACE-PARTVALUE-<internal_label>||#)

In case of multiselect, it is better to use PLAIN TEXT as type, and just put the reference to the part in the 'Visibility' box.

Chosen values form a multi-select contain X

return #REPLACE-PARTVALUE-<internal_label>||#.indexOf('X') >= 0

So we count the number of times that 'X' (index) occurs

Chosen values from a multi-select contain X or Y

Example: if the field ‘Multiselect’ contains ‘Conferenties’ OR ‘Diverse personeelskosten’, then show the second field.

var Conferenties = #REPLACE-PARTVALUE-Multiselect||#.indexOf('Conferenties');

var Diverse = #REPLACE-PARTVALUE-Multiselect||#.indexOf('Diverse personeelskosten');

if ((Conferenties >= 0) || (Diverse >= 0)) return true

else return false

Value (integer) is bigger than X

return #REPLACE-PARTVALUE-<internal_label>||# && Number(#REPLACE-PARTVALUE-<internal_label>||#) > X

Note: the internal label is entered twice

OR statement between 2 Yes/No fields:

var <internal_label> = #REPLACE-PARTVALUE-<internal_label>||#;

var <internal_label2> = #REPLACE-PARTVALUE-<internal_label2>||#;

if ((<internal_label> == "true") || (<internal_label2> == "true")) return true

else return false

It can also be like this:

var <internal_label> = #REPLACE-PARTVALUE-<internal_label>||#;

var <internal_label2> = #REPLACE-PARTVALUE-<internal_label2>||#;

return ((<internal_label> == "true") || (<internal_label2> == "true"))

Example:

var schriftelijke_toestemming_YN = #REPLACE-PARTVALUE-schriftelijke_toestemming_YN||#;

var mondelinge_toestemming_YN = #REPLACE-PARTVALUE-mondelinge_toestemming_YN||#;

return ((schriftelijke_toestemming_YN == "false") || (mondelinge_toestemming_YN == "false"))

If a number greater than 0 is entered in field A or in field B, display the third field:

Field 1 = Inschatting_aantal_deelnemers_0_tot_12_jaar

Field 2 : Inschatting_aantal_deelnemers_12_tot_18_jaar

This is the JS, please note ‘||’ as OR statement

var a0tot12 = Number(#REPLACE-PARTVALUE-Inschatting_aantal_deelnemers_0_tot_12_jaar||#);

var a12tot18 = Number(#REPLACE-PARTVALUE-Inschatting_aantal_deelnemers_12_tot_18_jaar||#);

return a0tot12 > 0 || a12tot18 > 0;

NOTE: in Javascript variables cannot start with a number!

Emptying values ​​from a fields

UZgent would like to have the option to un-select radio buttons.

We have already discussed this, and it is indeed not obvious.

After a discussion with UZ Gent, it turned out that the problem is there, but that another issue lies at the root.

The visibility rules are not switched in the SC. I explain myself further:

Relations

Field B is dependent of field A.

Field C is dependent of field B.

Type of fields

Field A : yes/no

Field B: yes/no : is only visible when 'Yes' on field A

field C: tekst field : is only visible when 'Yes' on field B

Scenario

I choose 'yes' at fields A& B, field C comes up = correct.

However, I then change field A to 'No', and because of that field B disappears, but field C remains.

C remains because the value of B is still set to 'yes', but B is no longer visible.

So , the entered 'yes' at field B will also be stored in the DB, but should actually be emptied.

So, long story short, if a field is not visible, the chosen value should be cleared. This is also important for later reports.

Solution

Set default value to dropdown, which refers to the yes/no, but always returns an empty string:

var temp = #REPLACE-PARTVALUE-JaNee||#;

return "";

Same for the text field, there you can choose either to set the trigger to yes/no or to set it to the dropdown (triggers work recursively)

var temp = #REPLACE-PARTVALUE-DropDownNaYesNo||#;

return "";

Phase = X

We want to show a field when the Phase = PhaseX

This is how to do it:

return #REPLACE-SERVICE-PHASE||Name# === 'PhaseX';

Show a field from phaseX

Phases have a built in order, and that is what we are using in this JS:var = currentphaseorders

We first get the Order of the phase the service is currently in :

Next, we get the Order of the phase from which we want to show this field, in this case 'PhaseX': var = targetphaseorders

Finally, we compare both values. This is the JS example:

var currentphaseorders = JSON.parse(CommonInterface.callWebservice('Get Phase Order By Name', { 'Name': #REPLACE-SERVICE-PHASE||Name# }));

var targetphaseorders = JSON.parse(CommonInterface.callWebservice('Get Phase Order By Name', { 'Name': 'PhaseX' }));

return currentphaseorders.length > 0 && targetphaseorders.length > 0 && +currentphaseorders[0].ItemOrder >= +targetphaseorders[0].ItemOrder;

Last updated