Create a related list from a LIST type field

Lavanya Nagendr
Giga Guru

Hi All,

 

We have a field 'Properties' which is an list type. This field contains values (i.e, careers, sports....), this relates to our 'Service Domain' field of Service CI (cmdb_ci_service) table.

 

So how many values selected in the 'Properties' field should result its related service domain CI's in the related list of the form.

 

Please help me on this.

 

Thanks!

2 ACCEPTED SOLUTIONS

@Lavanya Nagendr 

try this first and see if you can avoid scripting, I believe this will work if name field stores choice labels i.e. sports, career

current.addQuery('u_service_product.nameField', 'IN', parent.u_properties.getDisplayValue());

If not then use scripting

I hope I have provided enough guidance and you can take it from here based on your developer skills.

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

Thanks @Ankur Bawiskar 

 

It worked when i gave as addEncodedQuery, the below is the final query that worked for me

 

current.addEncodedQuery('u_service_product.u_nameIN'+ parent.u_properties.getDisplayValue());

 

Thanks for the help much appreciated!

View solution in original post

17 REPLIES 17

Chaitanya ILCR
Mega Patron

Hi @Lavanya Nagendr ,

you can create a custom relationship for this

ChaitanyaILCR_0-1740026306904.png

https://www.servicenow.com/community/now-platform-articles/how-to-create-scripted-relationships-or-d...

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Ankur Bawiskar
Tera Patron
Tera Patron

@Lavanya Nagendr 

related list should be on Service Table so do this

Applies to -> cmdb_ci_service

Queries from -> Table referred by Properties Field

Script:

current.addQuery('sys_id', 'IN', parent.u_properties.toString());

Once this is done then you will see Careers, Sports in related list of CI form

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 ,

 

Since i want this related list on the Properties field form, i did the opposite of your code but the related list is empty still.

 

Screenshot 2025-02-20 at 10.42.11 AM.png

 Thanks!

@Lavanya Nagendr 

u_service_product on properties table refer to which table

Share dictionary for that

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