Auto Populating a related list based on a list collector field

Tom_SCC
Giga Expert

Hi there,

 

As a MSP, on my companies table I have a related list showing the Business service that company(customer) is consuming. I also have a List collector field (u_services). I want it so when i update the list collector field, it will auto populate the related list. 

find_real_file.png

I believe this needs to be done via scripted business rule. I have  m2m relationship between companies and business services currently. I'm not great at scripting so wondered if someone has done this before and has a ready made script to perform this (minus the obvious difference in my field name)?

 

(I know you can use a related list to add or move records. I am using the list collector so i can report on customers consuming a particular service. for example, i wish to report on incidents closed last week for customers who have our Major incident management service. The incident forms themselves are using the technical business service to describe the issue.)

1 ACCEPTED SOLUTION

Hi

 

i figured it out in the end i used script

 

(function refineQuery(current, parent) {


current.addQuery('sys_id','IN',parent.u_services);


})(current, parent);

 

and this worked. Thanks

View solution in original post

3 REPLIES 3

Asbj_rn
Mega Expert

I do not have a plug'n'go script for you. 

 

but under system definition -> Relationships, you can create your own relations which are used to create the related list. 

 

It is fairly straightforward. Select the source table, Select the target table ( items to be queried), setup the query on based on the list collector.

have not been able to test this, but something like the below should get you closer if not all the way 🙂

(
    /**
     * @param {GlideRecord} current gliderecord used to query target table
     * @param {GlideRecord} parent gliderecord for the record that is opened.
     */
    function refineQuery(current, parent)
{
    current.addQuery('<nameOfField>', 'IN', parent.getValue('<fieldWithListCollector>'/**comma separated string value*/));
})(current, parent);

 

Thanks Asbjørn

 

so with my list collector field being u_services then the <nameofField> should be u_services? the field with list collector is the same field, though. So would that mean it would be u_services for both entries in that query?

(
    /**
     * @param {GlideRecord} current gliderecord used to query target table
     * @param {GlideRecord} parent gliderecord for the record that is opened.
     */
    function refineQuery(current, parent)
{
    current.addQuery('<nameOfField>', 'IN', parent.getValue('<fieldWithListCollector>'/**comma separated string value*/));
})(current, parent);

 

 

Hi

 

i figured it out in the end i used script

 

(function refineQuery(current, parent) {


current.addQuery('sys_id','IN',parent.u_services);


})(current, parent);

 

and this worked. Thanks