- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2024 11:46 AM
Hi !!
I am facing issue on how to copy values from left slushbucket in a list collector field to a multi line text field in a record producer using catalog client script.
I have a list collector field which contains some state values , as soon as the user selects some values ,I should exclude those selected values and copy remaing values (left slushbucket) values in a multi line text field.
My list collector field is referenced to select box variable that contains choice values on question choices table.
I am unable to populate the values on change of the list collector variable using catalog client script.
Please do help me with the code.
From the above screenshot , i should be able to populate display users field with all other values from left slushbucket excluding Hawaii & Michigan as soon as the user selects them in list collector variable.
Caltalog Client script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2024 08:47 PM
Hi @Pravallika1
There are a few adjustments needed. Below is the revised version of your script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var initialChoices = ['dc8b769893a0021035e6b2ddfaba10cc','1ecb365893a0021035e6b2ddfaba1009','4bebf65893a0021035e6b2ddfaba104e','fc2cfe9893a0021035e6b2ddfaba10e4','7d3cb6909320021035e6b2ddfaba10aa','2e5c3a9893a0021035e6b2ddfaba1066','b66c769893a0021035e6b2ddfaba10d6','ea8cf6d893a0021035e6b2ddfaba101f','ee9cf69893a0021035e6b2ddfaba10c8'];
var selectedChoices = g_form.getValue('test_users');
var selectedChoicesArray = selectedChoices.split(',');
var states = [];
for (var i = 0; i < initialChoices.length; i++) {
if (selectedChoicesArray.indexOf(initialChoices[i]) == -1) {
states.push(initialChoices[i]);
}
}
var gaStates = new GlideAjax('u_AjaxUtils');
gaStates.addParam('sysparm_name', 'getStatesDiff');
gaStates.addParam('sysparm_states', states);
gaStates.getXML(SetfieldValues);
function SetfieldValues(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('display_users', answer);
}
}
Script Include:
var AjaxUtils = Class.create();
AjaxUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getStatesDiff: function() {
var states = this.getParameter('sysparm_states').split(',');
var traineeEmailCollection = [];
for (var i = 0; i < states.length; i++) {
var gr = new GlideRecord('question_choice');
if (gr.get(states[i])) {
traineeEmailCollection.push(gr.text);
}
}
return traineeEmailCollection.join('\n');
}
});
HIT Helpful & Accept Solution !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2024 10:15 AM
Hi @Pravallika1 ,
Please mark as accepted solution & hit helpful !! if it helped you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2024 12:29 AM
Thanks all for you reply!!
I finally used this code to achieve my functionality.
Catalog Client Script: