Choice list based off a list field from another table

Patrick Carder1
Tera Expert

Hi All,

I'm looking to have a choice list on a record be based off a list field or string field with a comma separated value from a related record on another table.

Basically, we have a custom Contract table (u_contract) that is related to the Company table (core_company), and within this contract table we have a list of supported services called u_supported_services (this can be stored as a list field or string with comma separated value). So what we are looking to do is have the Category field on the incident record be dependant on what's in the related contract table.

Currently I've creating a business rule on the Incident table to do the below on update, however it only populates a single choice comprised of a the list as a csv value.

current.category = current.company.u_contract.u_supported_services
current.update();

The u_supported_services field on the u_contract table is created by another business rule that does the below. This looks at a number of true/false fields to add all the services marked as true to a list field.

var list = "";
if(u_field_1 == "true"){list+= "service1,";}
if(u_field_3 == "true"){list+= "service2,";}
if(u_field_3 == "true"){list+= "service3,";}
current.u_support_services = list;
current.update();

Alternatively I believe I could make u_supported_services a choice list field, which would make the business rule on the incident table work, however I'm not sure how you would build the choice field on the contract table.

Any suggestions here would be greatly appreciated.

Thanks in advance,
Patrick.

1 ACCEPTED SOLUTION

Tudor
Tera Guru

Hi Patrick,

You could potentially run an onChange client script which builds up the category using:

g_form.addOption and g_form.removeOption having in a background an Ajax Call to retrieve the data.

https://www.servicenowguru.com/scripting/client-scripts-scripting/removing-disabling-choice-list-options/

 

Another option would be a business rule on display which changes dynamically the reference qualifier of the category field. - haven't tested this one so don't know if it really works:)

Hope this helps!

Regards,

 Tudor

View solution in original post

1 REPLY 1

Tudor
Tera Guru

Hi Patrick,

You could potentially run an onChange client script which builds up the category using:

g_form.addOption and g_form.removeOption having in a background an Ajax Call to retrieve the data.

https://www.servicenowguru.com/scripting/client-scripts-scripting/removing-disabling-choice-list-options/

 

Another option would be a business rule on display which changes dynamically the reference qualifier of the category field. - haven't tested this one so don't know if it really works:)

Hope this helps!

Regards,

 Tudor