Display Configuration Item Based on First Selected Field in List Collector

LokeshwarRV
Tera Contributor

 

I need some help with a requirement in ServiceNow. I've created a List Collector with options like "Prod", "QA", and "Test". Here's what I'm trying to achieve:

  1. If multiple fields are selected in the List Collector (e.g., "Prod" and "QA"),
  2. I want to display the configuration item in the Service Catalog based on the first selected field.

For example, if "Prod" is the first selected field, then in sccatalog task in  configuration item should display something based on  sysId = 'aehhfh'. 
i have written this script  in configuration item  

var selectedFields = fd_data.trigger.request_item.variables.list_collector;
if( selectedFields.length>0){
var selectedFirst = selectedFields[0];
return sysid baed on that;
}

 

1 ACCEPTED SOLUTION

@LokeshwarRV 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@LokeshwarRV 

something like this, please enhance

var selectedFields = fd_data.trigger.request_item.variables.list_collector.toString().split(',');
if (selectedFields.indexOf('ProdSysIdhere') > -1) {
    return 'ciSysId1';
} else if (selectedFields.indexOf('QAsysIdhere') > -1) {
    return 'ciSysId2';
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@LokeshwarRV 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader