- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2023 05:14 AM
Hello Experts,
We have a requirement to show an alert whenever values are removed from List collector variable.
Example: below is a variable of type list collector having ids in it.
so if ID -33524 is removed then it should show an alert ('Caution: you are removing this ID');
How can we achieve this requirement?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2023 06:14 AM - edited 10-13-2023 06:15 AM
Do this by calling Glide Ajax from the OnChange Client Script on the List Collector Variable.
var ga = new GlideAjax('GetData');
ga.addParam('sysparm_name', 'getValueList');
ga.addParam('sysparm_value', newValue);
ga.addParam('sysparm_old_value', oldValue);
ga.addParam('sysparm_table', 'tablename');//add the table name List Collector is refering to
ga.getXML(ajaxResponse);
}
function ajaxResponse(serverResponse) {
// Make all requested updates to the form
var result = serverResponse.responseXML.getElementsByTagName('result');
alert ('Caution: you are removing this ID ':result);
}
Script Include :
getValueList: function() {
var table = this.getParameter('sysparm_table');
var newValue = this.getParameter('sysparm_value');
var oldValue = this.getParameter('sysparm_old_value');
newValue = newValue.split(',');
oldValue = oldValue.split(',');
var arr = new ArrayUtil();
var duplicatesRemoved = arr.diff(oldValue, newValue);
var dispVal = [];
for (var i in duplicatesRemoved) {
var tableGR = new GlideRecord(table);
tableGR.get(duplicatesRemoved[i]);
dispVal.push(tableGR.name); // whatever field it is that you want to display
}
return dispVal;
},
Regards,
Piyush Sain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2023 05:28 AM
Hello @Amit Rao
You need to write the below onChange Client Script :-
function onChange(control, oldValue, newValue, isLoading) {
alert("Caution: you are removing this" +oldvalue)
}
Plz mark my solution as Accept, If you find it helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2023 06:14 AM - edited 10-13-2023 06:15 AM
Do this by calling Glide Ajax from the OnChange Client Script on the List Collector Variable.
var ga = new GlideAjax('GetData');
ga.addParam('sysparm_name', 'getValueList');
ga.addParam('sysparm_value', newValue);
ga.addParam('sysparm_old_value', oldValue);
ga.addParam('sysparm_table', 'tablename');//add the table name List Collector is refering to
ga.getXML(ajaxResponse);
}
function ajaxResponse(serverResponse) {
// Make all requested updates to the form
var result = serverResponse.responseXML.getElementsByTagName('result');
alert ('Caution: you are removing this ID ':result);
}
Script Include :
getValueList: function() {
var table = this.getParameter('sysparm_table');
var newValue = this.getParameter('sysparm_value');
var oldValue = this.getParameter('sysparm_old_value');
newValue = newValue.split(',');
oldValue = oldValue.split(',');
var arr = new ArrayUtil();
var duplicatesRemoved = arr.diff(oldValue, newValue);
var dispVal = [];
for (var i in duplicatesRemoved) {
var tableGR = new GlideRecord(table);
tableGR.get(duplicatesRemoved[i]);
dispVal.push(tableGR.name); // whatever field it is that you want to display
}
return dispVal;
},
Regards,
Piyush Sain