Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Conditions "IF" in Variables or record Producer

DIVI1
Tera Expert

Hi,

I have a problem with adding a conditions to Variables. 
Look I have a couple fields like these: 

DIVI1_0-1693403861409.png

and I created a custom tables for data which are inside of those fields.

Now I want to see for example something like: 

If field division will be "cloating" then in field "group" you can see only record which have u_division_type like "cloating"  these parameters  I added to Table as a value in fields to recognize values.

 

How to prepare those part of code and
Where I can put script like this?

 

Right now I tried to use

DIVI1_1-1693404123758.png

but it's not dependent of division field...

5 REPLIES 5

Brad Bowman
Kilo Patron
Kilo Patron

Since group appears to be a List Collector type variable, be sure to add a Variable attribute

ref_qual_elements=division

where division is the name of the variable. This will ensure the list is updated when the division variable changes.

Your reference qualifier should look more like this:

javascript:"u_type=Group^u_division_typeIN" + current.variables.division

since division appears to be a list collector as well.  This is assuming 'Group' is the correct value stored in the table, not 'group', and your u_division_type field needs to be a reference to the table used by the division variable as that variable will be storing the sys_id(s) of the selected division records.  In case this editor still replaces text, the reference qualifier starts with javascript followed by a colon symbol then the quote.

Unfortunately, still not working... 😞

Look Here is a table with full data: 

DIVI1_0-1693471711489.png

and for now I have a fields on Service Portal in type as "List Collector" cause I want to get data from table from previous screen and then look for data based on conditions.

so first we have a field "division"

where we have only to choices: 

DIVI1_2-1693471900621.png

Here is a division variable

DIVI1_1-1693471863177.png

and if we will choose "cloathing" then I want to see in a group field only record which have u_division_type as 'cloathing' (technical name from table)

and similar for the second choice of division

 

 

Then I want to create something close like this for the choices of "Group" field

Also I added Attributes about which you wrote and same situation I can see full data in a field "Group"

like even records which have different u_type:

DIVI1_3-1693472357514.png

 

The value stored in the division List Collector variable will be a comma-separated list of sys_ids of the aClothing and bGeneral Merchandise table records (that have the u_type=Division) so a reference qualifier attempting to show only records in this table with that/those division types will only work if the u_division_type field on the table is a reference to the same table.  You can add a reference qualifier to this table field so that you can only choose Division type records.  Then the reference qualifier that I provided will show you only the Group type records which have a division type = to one of the selected divisions - also making sure to include the variable attribute on the group list collector variable and replace : with the colon symbol.