populate records of a custom table based on conditions.

abhisek
Tera Contributor

I have a catalog variable 'Is the exemption related to an incident or change' having 3 values neither, incident and change. Have another catalog variable 'which policy' refers to a custom table. The requirement is if the value of the catalog variable 'Is the exemption related to an incident or change' is selected as 'change' or 'incident' then only the policies that have the column INCCHGException= True will be shown for the variable 'which policy' and if the value of the catalog variable 'Is the exemption related to an incident or change' is selected as 'neither' then all values will be displayed.

 

Can anyone please help me out.

Thanks in advance.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@abhisek  

basically you will have to add reference qualifier on 2nd variable based on value of 1st so that it filters out the records

use this in 2nd variable's reference qualifier field

javascript: var query = ''; 
var val = current.variables.1stVariable; // give the variable name here
if(val == 'incident' || val == 'change')  // give here the correct choice values
query = 'columnName=true'; // give here the correct column name which has true/false value
query;

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Uncle Rob
Kilo Patron

SIMPLEST way (but has more nodes on the flow) is to simply *IF* it all out.

IF "exemptionRelated" = incident OR "exeptionRelated" = change
    lookup records in <custom table> with <conditions you want>
ELSE
    lookup records in <custom table> with <other conditions you want>

Ankur Bawiskar
Tera Patron
Tera Patron

@abhisek  

basically you will have to add reference qualifier on 2nd variable based on value of 1st so that it filters out the records

use this in 2nd variable's reference qualifier field

javascript&colon; var query = ''; 
var val = current.variables.1stVariable; // give the variable name here
if(val == 'incident' || val == 'change')  // give here the correct choice values
query = 'columnName=true'; // give here the correct column name which has true/false value
query;

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur Bawiskar 

Thanks for your reply.

I had tried this but not working.

@abhisek  

it should work.

I hope you have not copied it directly but made the necessary changes in your instance.

share what you did?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader