- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2022 03:48 AM
Hello!
We have an inbound action (reply) for a custom app. The requirements are:
(1) if ticket is closed for more than 7 days, create new ticket
(2) if ticket is closed for less than 7 days, update ticket
(3) if ticket is still open, update ticket
this is my script and working correctly for (1) and (3). it is not working for (2).
if (current.state == 3) {
var checkDate = new GlideDateTime(current.closed_at);
checkDate.addDaysLocalTime(-7);
if (checkDate > gs.nowDateTime()) { //check record is not closed before more than 7 days
if (current.state == 3) {
current.state = 2;
}
current.work_notes = email.body_text;
current.update();
} else {
<script to create new ticket>
current.insert();
}
}
else {
current.work_notes = email.body_text;
current.update();
}
Please help!
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2022 04:26 AM
Hello @ceraulo ,
Please try the below script:
if (current.state == 3) {
var checkDate = new GlideDateTime(current.closed_at);
var now = new GlideDateTime(gs.nowDateTime());
now.addDays(-7);
if (checkDate > now) { //check record is not closed before more than 7 days
current.state = 2;
current.work_notes = email.body_text;
current.update();
} else {
<script to create new ticket>
current.insert();
}
}
else {
current.work_notes = email.body_text;
current.update();
}
Please mark my answer as correct if it helps.
BR,
Nayan.
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2022 04:26 AM
Hello @ceraulo ,
Please try the below script:
if (current.state == 3) {
var checkDate = new GlideDateTime(current.closed_at);
var now = new GlideDateTime(gs.nowDateTime());
now.addDays(-7);
if (checkDate > now) { //check record is not closed before more than 7 days
current.state = 2;
current.work_notes = email.body_text;
current.update();
} else {
<script to create new ticket>
current.insert();
}
}
else {
current.work_notes = email.body_text;
current.update();
}
Please mark my answer as correct if it helps.
BR,
Nayan.
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 11:05 PM
This worked! Thank you.