- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2024 10:15 AM - edited 05-24-2024 10:16 AM
Hi All,
I have a custom field "incident state"(choice) on escalation log table, if incident state is updated on incident table, i need to update the "incident state"(choice) field
I have written after insert/update BR, but it is not setting the value, Not able to debug it, can anyone please suggest.
For the below code if I checked log, i am getting the value.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var inc_state = new GlideRecord('on_call_escalation');
inc_state.query('source',current.sys_id);
inc_state.query();
if(inc_state.next()){
inc_state.u_incident_state = current.state;
gs.log("esc inc state"+ inc_state.u_incident_state);
inc_state.update();
}
})(current, previous);
Thanks,
Saranya
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2024 10:26 AM
Hi @Saranya2,
Please update your code as below -
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var inc_state = new GlideRecord('on_call_escalation');
inc_state.addQuery('source',current.sys_id);
inc_state.query();
if(inc_state.next()){
inc_state.u_incident_state = current.state;
gs.info("esc inc state"+ inc_state.u_incident_state);
inc_state.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2024 11:50 AM
Hi @Saranya2 ,
Please check the code, you have 2 query statement and the second one is getting all data from On Call Escalation table.
Due to If condition, result set is iterating for first record only which may ( or may not ) be same Incident record.
replace below query with addQuery
inc_state.query('source',current.sys_id);
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2024 10:26 AM
Hi @Saranya2,
Please update your code as below -
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var inc_state = new GlideRecord('on_call_escalation');
inc_state.addQuery('source',current.sys_id);
inc_state.query();
if(inc_state.next()){
inc_state.u_incident_state = current.state;
gs.info("esc inc state"+ inc_state.u_incident_state);
inc_state.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2024 11:50 AM
Hi @Saranya2 ,
Please check the code, you have 2 query statement and the second one is getting all data from On Call Escalation table.
Due to If condition, result set is iterating for first record only which may ( or may not ) be same Incident record.
replace below query with addQuery
inc_state.query('source',current.sys_id);
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution