List collector values cleared when new value selected in alert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 02:04 AM
Hi
I have a List collector and I want to populate the values in a multi line text as well as display an alert message of the selection made .
But the alert message displays the entire values for all the items selected ,I want it to display only the values of item
Please help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 02:16 AM
so you want to populate data from that list collector into another variable?
What's the desired business outcome? please share screenshots.
what script did you start with and what's the issue? what debugging have you done so far?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 02:30 AM
There is a list collector and it displays topics at bottom ,this topic field has more values but due to word limit the list collector only displays certain text as shown below.
The topics for the item is more but only few is displayed, as a workaround I want to fetch the values and display them in a multi line variable and as an alert message ,so I wrote client script and glide ajax to achieve it.
But the issue I'm facing is the alert message if I select the second item it not displays the topic for that item alone ,it displays values along with previous topics of the selected item.
For selection of one item its corresponding topics is displayed as alert and its value is populated in the multi line variable ,
but when I select the second item the topic of the item along with previous selection topics is getting displayed. I want only the topics of the particular item displayed as alert.
Also in multi line variable the topics of item must be added after a line break from the previous topics populated .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 02:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 02:44 AM
Sure the client script and script include used .
//STRY0015100 : NEW CONDUKTOR SUMMARY CATALOG ITEM
//Script to populate the list collector field in multi line text variable in catalog form.
var grpValues = Class.create();
grpValues.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
grpDetails: function(){
var grpVal = [];
var grpList = this.getParameter('sysparm_record');
var Value = grpList.split(',');
for(var i=0; i< Value.length; i++){
var names = new GlideRecord('u_conduktor_summary');
names.addQuery('sys_id',Value[i]);
names.query();
while(names.next())
{
grpVal.push(names.u_topics);
}
}
return grpVal.join();
},
type: 'grpValues'
});
//STRY0015100 : NEW CONDUKTOR SUMMARY CATALOG ITEM
//Script to populate the multi line text field.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
g_form.clearValue('topics_of_the_item_selected');
return;
}
if(newValue == ''){
g_form.clearValue('topics_of_the_item_selected'); // clear the values
}
g_form.clearValue('topics_of_the_item_selected');
var grpList = g_form.getValue('select_group_name_s');
alert(grpList);
var ga = new GlideAjax('grpValues');
ga.addParam('sysparm_name','grpDetails');
ga.addParam('sysparm_record',grpList);
ga.getXML(CallBack);
function CallBack(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('topics_of_the_item_selected', answer.toString().split(',').join( ), +'\n');
alert("Topics selected: "+answer);
}
}