Creating a related list that queries from two fields (reference & list)

crainm
Kilo Explorer

I have successfully created a related list that queries a reference field from my destination table.

What I am having problems with are:

a) When my value is empty, it still queries the table for an empty value.   Would like it not to query at all.

b) When trying to add an OR condition so that it adds a list variable to the query.

My code is as follows

if (parent.u_automated=='Yes')

      current.addQuery('data', parent.u_data);

//This is what is not working

current.addQuery('data', parent.u_secondary);

      else {

//Not sure how to return nothing.   This works because they are two different fields, but not efficient.

      current.addQuery('data', parent.u_name);

}

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Michael,



Please refer below blog and adjust your code.


Defined Related Lists - ServiceNow Guru


View solution in original post

3 REPLIES 3

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Michael,



Please refer below blog and adjust your code.


Defined Related Lists - ServiceNow Guru


This helped me a lot on a) and I think b) is answered in there, but I am having issues with the array piece of the list variable and the addOrCondition.   I will get there eventually.


Thank you Michael for the update.


Please let me know if you are blocked.