List collector variable if i select A country then have A and B to be set in the same variable

srikriti
Tera Contributor

Hi All,

 

I have a scenario there is a list collector variable in catalog item referring to country table if i select US then US and united arab should populated in the same variable  how do i do this can any one guide me on this.

 

 

Thanks,

 

 

11 REPLIES 11

Hi !

 

This must help !

 

https://www.servicenow.com/community/developer-forum/populate-list-collector-variable-from-catalog-c...

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Nayan  Dhamane
Kilo Sage
Kilo Sage

Hello @srikriti ,

Please use an onchange client script on your country field.

Use the below codes in both of the scripts

Client Script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
   if (newValue.indexOf('sys_id of USA')>-1){
   g_form.setValue('your field name',newValue+',sys_id_of_uae');
   }
   //Type appropriate comment here, and begin script below
   
}
}

 

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.

hi @Nayan Dhamane 

it showing like this 

srikriti_0-1691486982670.png

srikriti_1-1691487021100.png

is there anything missing?

 

Hello @srikriti ,

Could you just put the newValue in alert and see what are you getting when you add multiple values. The no match found error might be mostly the sys_id did not match the value.

 

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.

Hi @Nayan Dhamane 

i donot want to use sys_id's can we replace with names ?