Retrieving list collector records and populating a field

Michael_Nash
Tera Contributor

Hi All,

 

I have a table  sn_customerservice_campaigns and the fields are u_kit(list collector) and u_kit_description (string)

u_kit(list collector) references sn_customerservice_part table and the fields I want to pull in are u_part_number and u_part_description.

 

when a part is selected in the u_kit field I need to get the number and the description to populate in the u_kit_description field

 

example (S1030006K001 - this is a description, A5001700B026 - This is a description).

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

Hi Michael,

A List field or List Collector Catalog Item variable store a comma-separated list of sys_ids for the referenced table.  What you'll need to do is use this value in an onChange Client Script when the list field/variable changes.  The Client Script will use GlideAjax to call a Script Include, passing in this value as a parameter.  The Client callable Script Include will query the referenced table where the sys_id is 'IN' this list passed in from the Client Script and for each record returned, append a string or array script variable with the number and description, then return the value of this script variable to the Client Script, which will set the value of the string field/variable to the returned value.  If you're not familiar on the syntax and methods for all of this, here is an excellent guide.

https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet-updated/ta-p/2... 

Give it a shot and post your scripts if you get stuck.

View solution in original post

4 REPLIES 4

Brad Bowman
Kilo Patron
Kilo Patron

Hi Michael,

A List field or List Collector Catalog Item variable store a comma-separated list of sys_ids for the referenced table.  What you'll need to do is use this value in an onChange Client Script when the list field/variable changes.  The Client Script will use GlideAjax to call a Script Include, passing in this value as a parameter.  The Client callable Script Include will query the referenced table where the sys_id is 'IN' this list passed in from the Client Script and for each record returned, append a string or array script variable with the number and description, then return the value of this script variable to the Client Script, which will set the value of the string field/variable to the returned value.  If you're not familiar on the syntax and methods for all of this, here is an excellent guide.

https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet-updated/ta-p/2... 

Give it a shot and post your scripts if you get stuck.

This Is awesome thanks @Brad Bowman  

You are welcome!

shubhamdubey
Mega Sage

Hi @Michael_Nash 

 

please refer this link . I have similar requirement and i have develop the code

 

https://www.servicenow.com/community/developer-forum/populate-the-multiple-serial-number-in-a-single...