Dynamically add items to List Collector from client script

pgiroux
Tera Contributor

Hi,

Just wondering if it's possible to dynamically add items to a list collector from within a client script.

The problem I'm trying to solve is the fact that we're grabbing information from a server script include - which reaches out to the ECC queue - and its returning information from a MID server powershell script to the client script.

We would like to have the ability to select one or more items when the results are returned. Currently I'm using a select box (with .addOption), but you can't select more than one at a time.

Is there anyway of transforming a List Collector variable (or a different form variable) into a multi-select variable that you could dynamically populate from a client script?

5 REPLIES 5

Unfortunately, there is not any other variable type that behaves like a list collector in the way you describe. List collectors are a way of collecting a list of referenced records and storing them into a single place. If you look at an Incident record that has users added to the watch list and look at the XML of that record you will see that the values of that list field are an array of sys_id values delimited by a comma. The watch_list field references the User [sys_user] table to show users that you can select from. You cannot store other values into a list type field or variable since it expects to reference a table and show the sys_id values   of those records in that table.



My guess is that it is very difficult to obtain all of the possible values that the PowerShell script returns and store them into a look-up table. However, you could have a second function in your script include that grabs the results of the PowerShell script, then attempts to look up in the look-up table for those records that match accordingly.



My guess is that you are just returned with a list of choices delimited in some way. You could iterate through that list and search each choice in the look-up table to see if it is there.


If it is, then capture the sys_id of the record and store it in an array.


If it is not, then create the record in the table and capture the sys_id after you create it and store it in the same array.


You would then pass back that array of sys_id values to your form to populate a string field that can be used to filter the choices from the list collector.


Since the list collector points to the look-up table and the Ajax call returns a filter string, the list collector will then only show those choices that you get from your PowerShell Script.



Let us know if this is a viable solution and if you need further assistance.