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

@Ankur Bawiskar I tried this and it's working. 

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

Valid? Do you see any issues with using this query?

 

Thank you,

Desmo

@Desmo 

looks good

Regards
Ankur

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

@Ankur Bawiskar You are top level. Thank you again.

 

Somewhat related to this. How would I dot-walk (query) to a field in the customer [core_company] table, i.e. Customer ID [u_customer_ID]? 

For example:

 
 
Applies to table: Contracts
Queries from table: Contacts

I want to query the Customer field in the Contracts table

GlideRecord? How? Sample would be appreciated.

Hi,

you can dot walk the first field if that's reference one using

example

current.addQuery('company.name', 'IN', parent.field.name);

Regards
Ankur

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

Hi,

The field is within the company table. Trying to get the value of a reference field's field, i.e. company.u_customer_id.

 

Regards,
Desmo