How to set resolution code to 'User error' using Client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 12:10 AM
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');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 05:42 AM
Hi Timothy,
What table is the client script defined on? Does the 'close_code' set of choice values include "User error" ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 06:31 AM
The Client script is defined on the incident table, and yes, "user error" is included in the choice types of 'close code'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 06:05 AM
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');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 07:42 AM - edited 11-05-2023 07:46 AM
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