Inbound action using current
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2022 10:54 AM
Hello all
I am trying to set an inbound action to stop updating a case when the case is closed. I have read various forum posts and believe that I have this setup right, however every time the reply comes into the instance I am receiving.
"Update HR Payroll Case : did not create or update sn_hr_core_case_payroll using current"
My inbound action has an Action Type == Record Action
Script:
gs.include('validators');
if (current.getTableName() == "sn_hr_core_case_payroll") {
var hrPayroll = current;
if(hrPayroll == false){
gs.log('>>>>>>>>>>MArk log');
hrPayroll.comments('User replied to a Closed incident. Auto-reply notification sent to the user');
hrPayroll.update();
}
hrPayroll.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
if (email.body.assign != undefined)
hrPayroll.assigned_to = email.body.assign;
hrPayroll.update();
}
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2022 11:54 AM
Hi Mark,
I'm not sure about
if(hrPayroll == false){
I would propose checking whether the case is closed, a condition similar to
if (hrPayroll.getValue('state') == '9') { //please adjust the name of the field and the value, I have taken it from the incident
Best Regards,
Marcin
If my answer helped you in any way, please mark this answer as helpful and correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2022 07:09 AM
Thanks for the reply Marcin,
I managed to get this working in the end thanks to your guidance and some serious head scratching and loads of testing,
this is what I ended up with:
if (current.getTableName() == "sn_hr_core_case_payroll") {
if (current.state == 3) {
current.work_notes = 'User replied to a Closed incident. Auto-reply notification sent to the user';
gs.eventQueue('sn_hr_core.hr_case.closed', current, 'hello', gs.getUserName());
} else {
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
if (email.body.assign != undefined)
current.assigned_to = email.body.assign;
}
current.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2022 11:55 AM
Hello Mark,
"var hrPayroll = current;" what are you trying to do here? ---- Remove this statement
Next line, "if(hrPayroll == false){", here, I believe you want to check the active state, use "if(current.active == false){"
below every where, replace "hrPayroll" with "current"
current.comments('User replied to a Closed incident. Auto-reply notification sent to the user'); current.update();
}
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
if (email.body.assign != undefined)
current.assigned_to = email.body.assign;
current.update();
}
Regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2022 07:18 AM
Please try to use:
if(hrPayroll.active == false)