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

@Ankur Bawiskar 

 

'u_properties' is the list field in the 'Properties' table which holds (careers, sports etc.,).

 

And on the Service Table we have a field 'u_service_product' field which is a reference field. This u_service_product field also have values (like careers, sports).

 

So we need a related list on the Properties table , if 'sports and careers' is selected on the 'u_properties' field this related list should display Services that has 'u_service_product' is one of 'u_properties'.

 

Note: u_properties field list refers to 'Choices' table while the 'u_service_product' on the Service table refers to completely different table.

 

Thanks!

@Lavanya Nagendr 

basically you can query the CI table with current service and show it

// your query to CI able and bring all CIs for this product

current.addQuery('sys_id', 'IN', sysIdArray.toString()); // this array will hold CI sysids

it's very difficult to understand without having a diagrammatic view of the tables involved

I believe I have provided enough guidance.

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

@Lavanya Nagendr 

you are not sharing the complete details

1) u_properties on Properties table points to sys_choice table

2) Service (cmdb_ci_service) table has u_service_product reference field pointing to which different table? Also that different table has these values sports, careers in which field?

unless this clarity is there I can't help

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

@Ankur Bawiskar 

1. u_properties on Properties table points to sys_choice table   -- YES

2. Service (cmdb_ci_service) table has u_service_product reference field pointing to which different table?    --- 'Product/Platform' table

3. Also that different table has these values sports, careers in which field?  ---  'name' field

 

Thanks!

@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