How to write List collector variables in advanced reference and script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 03:30 AM
1. How to pass variable in script include
2.How to write syntax for list collector variables in reference qualifier
3. Based on software product variables in List collect variable software version is populate
4.Backend name for software variable is software_product.
Let me know how to write on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 03:34 AM
<div/>List collector variables are a type of variable used in ServiceNow to capture multiple values in a single field. Here's how to write List collector variables in advanced reference and script include:
- Advanced reference: In an advanced reference field, you can use the GlideList object to access the values of a list collector variable. Here's an example code snippet:
This code creates an empty array called "values", and then loops through each value in the list collector field, adding it to the array.
- Script include: In a script include, you can access the values of a list collector variable using the same GlideList object. Here's an example code snippet:
This code defines a function called "getValuesFromListCollector" that takes the name of the list collector variable as a parameter. The function creates a new GlideList object and uses it to get the values of the variable. It then loops through each value in the list collector field, adding it to an array called "values". The function returns the array of values.
By using these code snippets, you can easily access the values of a list collector variable in an advanced reference or script include in ServiceNow.</div>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 03:38 AM
since you are passing list collector you should query like this
gr.addQuery('u_product_grouping_id', 'IN', input.toString());
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 03:56 AM
I'm passing reference variable that is software product
What about reference qualifier syntax
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 04:04 AM
@Anish9515
You should add reference qualifier as below-
javascript:new scriptIncludeName().functionName(software_product_variable_name);
as per your screenshot-function name is-productVersion()
Thanks,
Manjusha Bangale