Remove options/Options control of a choice list in Agent workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2020 02:12 AM
HI,
On the incident form we have a client script running that uses a GlideAjax to filter categories based on a parameter on the incident form.
This works nicely on the normal forms, but it doesn't work on the agent workspace.
I've did some debugging and it seems that the Agent workspace does not support g_form.getControl/g_form.removeOption/g_form.addOption methods?
The info message, in the screenshot, shows the result of which categories should be visible. For this example only 1 category, Security, should be available but all the categories are still available.
Client script to remove and add the categories
//Loop through all existing category options
var options = g_form.getControl('category').options;
//g_form.addInfoMessage(options.length);
for (var k = options.length; k--;){
//Dont remove current category & -- none --
if(options[k].value != currentCategory && options[k].value != ''){
//g_form.addInfoMessage('Remove option ' + k + options[k].value);
g_form.removeOption('category', options[k].value);
}
}
//g_form.addOption('category','','-- None --');
for( var i=0 ; i < answer.length ; i++) { //Loop into the array
//g_form.addInfoMessage(answer[i].name + " - " + answer[i].value);
if(answer[i] != currentCategory){
g_form.addOption('category', answer[i].value, answer[i].name);
}
}
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2020 04:01 AM
Hi Mathias,
I am also facing the same issue in Agent workspace. Did you identified any workaround for this issue. Please let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2020 05:13 AM
Hi Mohammad,
the issue wasn't the script I posted here. I used a GlideAjax to get the categories link to a certain fulfiller group. The issue was that you have to parse the JSON you get back from the GlideAjax differently in the Worspace than on normal forms.
I solved it witch a try and catch so i could you the same client script for both forms.
function getAnswer(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
//g_form.addInfoMessage(answer); //JSON String
try {
answer = answer.evalJSON();
} catch (e) {
answer = JSON.parse(answer);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2021 04:02 AM
Have you found answer for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2021 04:19 AM
Hi Iaksmhik,
My solution is written here above