How to set resolution code to 'User error' using Client script

Timothy Oyetade
Tera Contributor

Hello,

I am trying to set the resolution code to 'user error' upon setting the state to 'Resolved' and Assigned to 'Fred Luddy' but my code seems not to be working at all.

Thank you for the help.

 

function onSubmit() {
//Type appropriate comment here, and begin script below
var Stat = g_form.getValue('state');
var Assignedp = g_form.getValue('assigned_to');
var res = g_form.getValue('close_code');
var resn = g_form.getValue('close_note');
if( Stat == '6' && Assignedp == '5137153cc611227c000bbd1bd8cd2005')
{
g_form.setValue('close_code','User error');
g_form.setValue('close_note', 'cant be resolved');
}
}

6 REPLIES 6

Bert_c1
Kilo Patron

Hi Timothy,

 

What table is the client script defined on? Does the 'close_code' set of choice values include "User error" ?

The Client script is defined on the incident table, and yes, "user error" is included in the choice types of 'close code'

Harish Bainsla
Kilo Patron
Kilo Patron

function onSubmit() {
var Stat = g_form.getValue('state');
var Assignedp = g_form.getValue('assigned_to');

if (Stat == '6' && Assignedp == '5137153cc611227c000bbd1bd8cd2005') {
g_form.setValue('close_code', 'user_error');
g_form.setValue('close_notes', 'Can't be resolved');
}
}

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Timothy Oyetade ,

 

Close code is a choice field (drop down).

Hope u are using proper value for "user error" which u have set on close code at dictionary level. Once those values match,ur code will work perfectly.

 

For eg at close code u have create User Error as user_error.

 

Then try the below script

 

function onSubmit() {
//Type appropriate comment here, and begin script below
var Stat = g_form.getValue('state');
var Assignedp = g_form.getValue('assigned_to');
var res = g_form.getValue('close_code');
var resn = g_form.getValue('close_note');
if( Stat == '6' && Assignedp == '5137153cc611227c000bbd1bd8cd2005')
{
g_form.setValue('close_code','user_error');
g_form.setValue('close_note', 'cant be resolved');
}
}

 

If you have not created it u can create by right clicking on the close code field. Then select configure dictionary.

Scroll at the bottom u will choices, create one more entry as user error.

Label can be User Error,

Value can be user_error.

 

Attaching screenshot for same

 

Thanks,

Danish