- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2024 10:58 PM
Hi Team,
In incident table how to auto change assignment group back to previous group after 5 min if no update.
Regards,
Tharun
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2024 11:06 PM
Hi @Tharun13
Use below code, I have tested it. It will work now.
gs.sleep(5 * 1000 * 60);
var dur = new GlideDuration();
dur.setValue(current.sys_created_on);
var gdt = new GlideDateTime(); //Always UTC +0
var duration2 = new GlideDuration();
duration2.setValue(gdt.getValue());
var answer = duration2.subtract(dur);
if (answer.getDisplayValue().split(' ')[0] >= 5) {
var incGR = new GlideRecord('incident'); // change table name
incGR.addQuery('sys_id', current.sys_id);
incGR.query();
if (incGR.next()) {
var gr1 = new GlideRecord("sys_audit");
gr1.addQuery("tablename", "incident"); // change table name
gr1.addQuery("documentkey", incGR.sys_id);
gr1.addQuery("fieldname", "assignment_group");
gr1.orderByDesc("record_checkpoint");
gr1.setLimit(1);
gr1.query();
if (gr1.next()) {
gs.log('old group' + gr1.oldvalue);
current.assignment_group = gr1.oldvalue;
current.setWorkflow(false);
current.update();
}
}
}
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 01:34 AM
put logs and see where it breaks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 01:37 AM
Not able to save the incident form, when we click on save this is still loading.
Regards,
Tharun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 04:27 AM
Hi @Tharun13 ,
Create Async business rule and use below code.
gs.sleep(5 * 1000 * 60);
var dur = new GlideDuration();
dur.setValue(current.sys_created_on);
var gdt = new GlideDateTime(); //Always UTC +0
var duration2 = new GlideDuration();
duration2.setValue(gdt.getValue());
var answer = duration2.subtract(dur);
if (answer.getDisplayValue().split(' ')[0] >= 5) {
current.assignment_group = previous.assignment_group;
current.update();
}
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2024 10:28 PM
Hi Runjay,
Group not changing, please help on this.
Regards,
Tharun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2024 11:06 PM
Hi @Tharun13
Use below code, I have tested it. It will work now.
gs.sleep(5 * 1000 * 60);
var dur = new GlideDuration();
dur.setValue(current.sys_created_on);
var gdt = new GlideDateTime(); //Always UTC +0
var duration2 = new GlideDuration();
duration2.setValue(gdt.getValue());
var answer = duration2.subtract(dur);
if (answer.getDisplayValue().split(' ')[0] >= 5) {
var incGR = new GlideRecord('incident'); // change table name
incGR.addQuery('sys_id', current.sys_id);
incGR.query();
if (incGR.next()) {
var gr1 = new GlideRecord("sys_audit");
gr1.addQuery("tablename", "incident"); // change table name
gr1.addQuery("documentkey", incGR.sys_id);
gr1.addQuery("fieldname", "assignment_group");
gr1.orderByDesc("record_checkpoint");
gr1.setLimit(1);
gr1.query();
if (gr1.next()) {
gs.log('old group' + gr1.oldvalue);
current.assignment_group = gr1.oldvalue;
current.setWorkflow(false);
current.update();
}
}
}
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------