Populate values based on selection of options in list collector field

suuriya
Tera Contributor

Hi,

 

I have a requirement, in catalog form there are 3 fields namely Select site name, Select Print groups and Printers included in group (FYI select print groups is dependent on select site name field) If any value is selected in select Print groups field, then printers' details need to populate in printers included in group field.

 

Select Print groups field is a list collector so multiple options can be selected...For example if i select "print group - tampa" in Select Print groups field then TAM-DV, TAM- SAT, Barcode these values need to be populate in Printers included in group field....likewiswe if i select more than 1 value in list collector field then respective printers details need to be populate in the field

 

Example

suuriya_0-1698179451858.png

in this case 2 values selected so AM-DV, TAM- SAT, Barcode and zebra tear, zebra 00 zebra 10 these values need to be populate in printers included in group field

 

There are multiple options present in select print groups so based on selecting each option a set of printer details need to populate in printers field....I have list of printer details related to each group in excel.

 

How can we achieve this.....please help me with entire onchange script.

 

Thanks in advance

13 REPLIES 13

Hi @Harish KM ,

 

Thanks for the help it worked....but in u_kallik_site_codes_and_access_groups table when i start adding new printer values then multiple values are getting displayed here

suuriya_0-1698227634401.png

here only single value needs to be display....how can we do that

in this field reference qualifier is added to display so 

suuriya_1-1698227971234.png

 

Hi @suuriya How come duplicate values occur. Do you have duplicate values in your table for different printers? If yes then you need to eliminate duplicate values

Regards
Harish

@Harish KM ,

 

These values are getting because whenever im creating new record in kallik table...here you can see there are 3 printer for PrintGroup- Tampa so in portal 3 PrintGroup- Tampa is getting displayed so i change this to

suuriya_0-1698228431353.png

this

suuriya_1-1698228630263.png

now only one print group tampa display but the problem is if i select that print group tampa then all 3 printers need to populate but as of now only one value gets populate....i think we are take just one record in script how we can change that.

 

This happen in this case also only one value populates

suuriya_2-1698228760305.png

 

 

Hi @suuriya The below script should do it. Modify the script include like below

getApplication: function() {
var CI = [];
var answer = [];
var sysId = this.getParameter('sysparm_sys_id');
gs.info("har" + sysId);
var almAssetGr = new GlideRecord("u_kallik_sites_codes_and_access_groups");
almAssetGr.addQuery('sys_id', "IN", sysId);
almAssetGr.query();
while (almAssetGr.next()) {
CI.push(almAssetGr.getValue('u_printer'));

}

var gr = new GlideRecord("u_kallik_sites_codes_and_access_groups");
gr.addQuery('u_printer', "IN", CI.toString());
gr.query();
while (gr.next()) {
answer.push(gr.getValue('u_printer'));
}
gs.info("hari" + answer.join(","));
return answer.join();


},

 

Regards
Harish