- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2018 02:19 AM
Hi,
I tried the update the incident state to 'resolved', after click on 'Withdrawal' button by customer.
if (input && input.action) {
var action = input.action;
// If Incident table
if (data.table == 'incident') {
if (action == 'withdrawal') {
// Withdrawal Incident
gr.setValue('incident_state', 6);
gr.setValue('state', 6);
//gr.setValue('close_code', 'Resolved by Caller');
//gr.setValue('close_notes', 'test data by user');
gr.setValue('resolved_by', gs.getUserID());
gr.setValue('resolved', gs.nowDateTime());
gr.update();
}
}
While updating the incident, it creating a new incident with same incident number and different sys_id and updating as 'resolved'.
is anyone faced the same issue or any suggestion in above code.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2018 04:04 AM
Can you confirm if "Withdrawal" is present on incident table and if yes please use following:
if (input && input.action) {
var action = input.action;
// If Incident table
if (data.table == 'incident') {
if (action == 'withdrawal') {
// Withdrawal Incident
var gr = new GlideRecord(data.table);
gr.addQuery('sys_id', data.sys_id);
gr.query();
if(gr.next()){
gr.setValue('incident_state', 6);
gr.setValue('state', 6);
gr.setValue('resolved_by', gs.getUserID());
gr.setValue('resolved', gs.nowDateTime());
gr.update();
}
console.log('new sys_id :'+String(gr.sys_id));
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2018 02:59 AM
Hi,
Can you please check gr is referring to which object.
Thanks,
Prateek

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2018 03:18 AM
Hi,
Use current object instead of gr
I think in your script gr is not refering to any object
Thanks,
Tripti.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2018 03:25 AM
if this is your complete script then your gr object is not defined and not referred to anything.
Replace it with current and try
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2018 03:42 AM
if (input && input.action) {
var action = input.action;
// If Incident table
if (data.table == 'incident') {
if (action == 'withdrawal') {
// Withdrawal Incident
gr = new GlideRecord(data.table);
gr.addQuery('sys_id', data.sys_id);
gr.query();
gr.setValue('incident_state', 6);
gr.setValue('state', 6);
//gr.setValue('close_code', 'Resolved by Caller');
//gr.setValue('close_notes', 'test data by user');
gr.setValue('resolved_by', gs.getUserID());
gr.setValue('resolved', gs.nowDateTime());
gr.addQuery('sys_id', data.sys_id);
gr.addQuery('number', data.number);
gr.update();
console.log('new sys_id :'+String(gr.sys_id));
}
}
}
I had change gr to current object, In the above case. it creating new incident with state as 'resolved'.