Remove options/Options control of a choice list in Agent workspace

Mathias Vandend
Mega Sage

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.

find_real_file.png

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);
				}
			}

 

5 REPLIES 5

Mohammad Sannav
Tera Expert

Hi Mathias,

I am also facing the same issue in Agent workspace. Did you identified any workaround for this issue. Please let me know.

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);

}

Lakshmi Kalatip
Tera Contributor

Have you found answer for this?

Hi Iaksmhik,

 

My solution is written here above