The CreatorCon Call for Content is officially open! Get started here.

Relationship: Help with OR statement and query list field

Desmo
Mega Guru

Hello Community,

I've created a relationship  where 'Applies to table' and 'Queries from table' are the same tables.

This query works.

	current.addQuery('customer', parent.customer);

Next, I'd like to include or statement and query a list field

	current.addQuery('customer', parent.customer);//or...
	current.addQuery('customer', parent.u_related_customer);//u_related_customer list field

 

Thank you!

1 ACCEPTED SOLUTION

@Desmo 

try this once

current.addQuery('customer', parent.customer).addOrCondition('u_related_customer', 'LIKE', parent.customer);

Regards
Ankur

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

View solution in original post

9 REPLIES 9

pony_ma
Kilo Contributor

Hi,Try whether this method is feasible

addEncodedQuery(String query)

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you cannot compare reference field with list field directly

you need to query and check

Regards
Ankur

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

@Desmo 

try this once

current.addQuery('customer', parent.customer).addOrCondition('u_related_customer', 'LIKE', parent.customer);

Regards
Ankur

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

@Ankur Bawiskar This is helpful.

I reversed the last condition and it produced results.

current.addQuery('customer', parent.customer).addOrCondition('customer', 'LIKE', parent.u_related_customer);

However, it does not produce results when there is more than one (1) entry in u_related_customer list field.

 

Regards,

Desmo