
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2024 08:34 AM
Hi Ankur,
Hope you are doing well and i believe you can help on the below requirement.
I have a requirement to check if any additional comments were added by a user not older than 3 business days .
And if so the ticket will be considered as escalated ticket .
I wrote below script to check if any additional comments were added or not but I am not sure how to exclude non-business days (Saturday ,Sunday)
For example if an user add additional comments on Friday at 11 am then Saturday and Sunday should not be calculated , till Wednesday 11 am the user will have the time to add his next additional comment in the ticket .
Could you help me with the script to achieve the mentioned requirement ?.
var grSec = new GlideRecord(table); //table represent incident
grSec.addQuery('sys_id',sys_id); //sys_id represent record sys_id
grSec.query();
if(grSec.next()){
if(table=='incident'){
if(grSec.escalation==1){
var secjournal=new GlideRecord('sys_journal_field');
secjournal.addQuery('element_id',sys_id);
secjournal.addQuery('element','comments');
secjournal.orderByDesc('sys_created_on');
secjournal.setLimit(1);
secjournal.query();
if(secjournal.next()){
var diffSec = gs.dateDiff(secjournal.sys_created_on, gs.nowDateTime(), true);
if (diffSec >259200) // 3 days - 259200
{
secEsc=true; //secEsc represent the ticket is eligible for second escalation
}
}
}
}
}
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2024 09:20 AM
Hi @diNesh_M ,
You can use GlideSchedule() API to include any schedule which you can create to include only business days.
Something like below,
var startDate = new GlideDateTime('2014-10-16 02:00:00');
var endDate = new GlideDateTime('2014-10-18 04:00:00');
var schedule = new GlideSchedule();
schedule.load('090eecae0a0a0b260077e1dfa71da828'); // loads "8-5 weekdays excluding holidays" schedule
var duration = schedule.duration(startDate, endDate);
gs.info(duration.getDurationValue()); // gets the elapsed time in schedule
But, I would still tell you to think any other way, instead to GlideRecord('sys_journal_field') table, since it's very huge.
You, can create a custom field on the Incident table where Additional comments changes and updated by is Caller, and capture the time in that field. Now compare with this field, instead of GlideRecord('sys_journal_field'). Just my thoughts.
If this information helps you, Kindly mark it as Helpful.
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2024 09:20 AM
Hi @diNesh_M ,
You can use GlideSchedule() API to include any schedule which you can create to include only business days.
Something like below,
var startDate = new GlideDateTime('2014-10-16 02:00:00');
var endDate = new GlideDateTime('2014-10-18 04:00:00');
var schedule = new GlideSchedule();
schedule.load('090eecae0a0a0b260077e1dfa71da828'); // loads "8-5 weekdays excluding holidays" schedule
var duration = schedule.duration(startDate, endDate);
gs.info(duration.getDurationValue()); // gets the elapsed time in schedule
But, I would still tell you to think any other way, instead to GlideRecord('sys_journal_field') table, since it's very huge.
You, can create a custom field on the Incident table where Additional comments changes and updated by is Caller, and capture the time in that field. Now compare with this field, instead of GlideRecord('sys_journal_field'). Just my thoughts.
If this information helps you, Kindly mark it as Helpful.
Regards,
Najmuddin.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2024 12:11 AM
Hi Najmuddin,
Thanks for your input ,will try the script you mentioned and will keep you posted if it works as expected .
Thanks