- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2020 11:24 AM
I have an onChange client script that collects an array of values (groups) that the user selected is in. How can I add these values in a select box as options?
I want those values in the "Existing HLA Access in Group(s):" field to be options in remove from group. For example: "Domain RTR Admins", "Domain CyberArk Users", and "Domain SMS Users-WAN" as options in the "Remove from Group" Select Box. The text in that field will change whenever the requested for is changed, so I need to create a functionality that will populate the selectbox options with that.
Here is the client script to populate the first text field:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('getHLAGroups');
ga.addParam('sysparm_name', 'groupHLA');
ga.addParam('sysparm_userSelect', g_form.getValue('u_user_hla'));
ga.getXML(updateGroup);
}
function updateGroup(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
// alert('Answer is: '+answer);
answer = answer.slice(0, -1);
var inAnswer = answer.split(';');
var outData = '';
for (var i=0; i < inAnswer.length; i++) {
outData = outData+'\n'+inAnswer[i].toString();
}
g_form.setValue('u_group_hla', outData);
}
I tried this:
myArray = answer.split(",");
var a = myArray[0];
alert(a);
g_form.addOption('remove_from_group', 'myArray[0]','myArray');
but it keeps adding "MyArray" as the only option in the select box.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2020 11:28 AM
try below
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('getHLAGroups');
ga.addParam('sysparm_name', 'groupHLA');
ga.addParam('sysparm_userSelect', g_form.getValue('u_user_hla'));
ga.getXML(updateGroup);
}
function updateGroup(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
// alert('Answer is: '+answer);
answer = answer.slice(0, -1);
var inAnswer = answer.split(';');
var outData = '';
for (var i = 0; i < inAnswer.length; i++) {
outData = outData + '\n' + inAnswer[i].toString();
g_form.addOption('u_group_hla', inAnswer[i].toString(), inAnswer[i].toString());
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 07:15 AM - edited 03-06-2023 07:15 AM
country: function() {
var bu = this.getParameter('sysparm_bu');
gs.log("I am Business" + bu);
var arr = [];
var gr = new GlideAggregate('u_oracle_financial_approvals');
gr.addQuery('u_business_unit', bu);
gr.groupBy('u_country');
gr.query();
gs.log("Tejas" + gr);
while (gr.next()) {
var obj = gr.getValue('u_country');
arr.push(obj);
gs.log("Result", +arr);
}
return arr.join(',');
},
OnChange Catalog Client Script -
var rf = g_form.getDisplayValue('u_business_unit');
alert('Hi, I am ' + rf);
var ga = new GlideAjax('Oracle_Business_Units');
ga.addParam('sysparm_name', 'country');
ga.addParam('sysparm_bu', rf);
ga.getXML(setAnswer);
function setAnswer(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('country', answer);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 11:04 PM
Hi @mike_allgire ,
I am getting output as below -
It is giving all values of country plus expected countries in single line as one option with comma separated values
I want highlighted values as options in that field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2023 07:15 AM
Are you trying to select more than a single value in a Lookup Select Box? If so, that is your issue. Lookup Select Box is a single value entry. If you use a list, then you can select multiple values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2023 07:31 AM
Hi @mike_allgire ,
I am not looking for multiple values to select, I am getting the whole array like below as a single option in that variable
Australia, Argentina, India, USA, Vietnam
I want to separate the above values as single option to be selected, like:
Australia
Argentina
India
USA
Vietnam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2023 07:58 AM
So you are wanting to filter the Country available values based on the BU selected in another Lookup Select Box? If so, can you share your Lookup Select Box configuration for each?
