remove option from assignment group

Miroslav5
Tera Contributor

Hello Guys, I made easy clienet script but absolutely dont know why its not working. My task is, when caller_id is tieto_integration_user and state changes to resolved, then exclude fujitsu service desk from assignment group so SD cant choose this group for resolving ticket. But its not working and dont know why.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

var callerId = g_form.getValue('caller_id');
var tietoUserId = '4044c51bdba29f007210fba6689619e5'; //sys_id of tieto_user

// Check if caller is 'tieto_user' and state is 'Resolved'
if (callerId === tietoUserId && newValue === '6') {
// Restrict selection of 'Fujitsu Service Desk' in assignment group
var fujitsuServiceDesk = '1c1cc2e2c867ab00b051c7906960cf3e'; //sys_id of fujitsu SD
g_form.removeOption('assignment_group', fujitsuServiceDesk);
} else {

}


}

7 REPLIES 7

Sandeep Rajput
Tera Patron
Tera Patron

@Miroslav5 Remove option only works on the choice field, and will not work in case of a reference field. Here in your case you are trying to remove a sys_id from assignment_group field which is a reference field and you will not be able to use removeOption on the reference field.

 

For more information please refer to https://developer.servicenow.com/dev.do#!/reference/api/utah/client/c_GlideFormAPI#r_GlideFormRemove...

 

Hope this helps.

For validation, you best bet would be to either use a GlideAjax inside an onSubmit script to check if the user has selected an incorrect group or use an onBefore insert validate to setAbortAction(true); if an incorrect group was chosen.

 

Hope this helps.

Thank you, I didnt know that it can be used just for choice filed. Please can you explain little bit more what solution do you regarding? My task is, when incident comes thru integration from tieto (caller tieto_user) and I resolving the ticket, there should not be able to choose fujitsu from assignment group, becouse SD sometimes choose fujitsu incorectly

Is there any possibility to hide this group when conditions met or just make abort action with message....What should be the best looking solution?