The CreatorCon Call for Content is officially open! Get started here.

Way to include request in report on which within 2 hours work notes are added after creation

raj chavan
Tera Guru
Tera Guru

is there any way to include request in report on which within 2 hours work notes are added after creation of that request for particular catalog item i want to create a report.

Kindly mark it correct and helpful if it is applicable.

Thanks,

Raj
1 ACCEPTED SOLUTION

raj chavan
Tera Guru
Tera Guru

To get this done i created one custom field (checkbox) on RITM table (hide it on front end) 

(function executeRule(current, previous /*null when async*/) {

    //  work notes are updated
    if (!current.work_notes.nil()) {
    
        var creationTime = new GlideDateTime(current.sys_created_on);
        var currentTime = new GlideDateTime();

        // calculate the difference in seconds
        var diffSeconds = (currentTime.getNumericValue() - creationTime.getNumericValue()) / 1000;

        // Convert seconds to hours
        var diffHours = Math.round(diffSeconds / 3600);

      

        //  difference is within 2 hours and if the item is "Market Research"
        if (diffSeconds <= 7200 && current.cat_item == '5a1efa5947520510f53d37d2846d439b') {
            current.u_earlyresponce = true; // Set early response to true
        } else {
            current.u_earlyresponce = false; // Set early response to false
        }
    }

})(current, previous);

From this i was able to get the RITM on which work notes are added within 2 hours 

Kindly mark it correct and helpful if it is applicable.

Thanks,

Raj

View solution in original post

3 REPLIES 3

MS25
Mega Sage

you can create report on sys_journal_field which stores journal entries data

Apply filter as per your requirement with created/updates date

1) element - work_notes

2) name - your table name

 

Please mark this answer helpful and correct if it helps you so others can benefit from this answer.

SO i wanted result for one particular catalog item that was i'm able to filer from item field on RITM table but still when i run report it is returning all the notes on RITM Table also i am not able to filter the worknote which are only added within 2 hours and it need to exclude other notes in report 

Kindly mark it correct and helpful if it is applicable.

Thanks,

Raj

raj chavan
Tera Guru
Tera Guru

To get this done i created one custom field (checkbox) on RITM table (hide it on front end) 

(function executeRule(current, previous /*null when async*/) {

    //  work notes are updated
    if (!current.work_notes.nil()) {
    
        var creationTime = new GlideDateTime(current.sys_created_on);
        var currentTime = new GlideDateTime();

        // calculate the difference in seconds
        var diffSeconds = (currentTime.getNumericValue() - creationTime.getNumericValue()) / 1000;

        // Convert seconds to hours
        var diffHours = Math.round(diffSeconds / 3600);

      

        //  difference is within 2 hours and if the item is "Market Research"
        if (diffSeconds <= 7200 && current.cat_item == '5a1efa5947520510f53d37d2846d439b') {
            current.u_earlyresponce = true; // Set early response to true
        } else {
            current.u_earlyresponce = false; // Set early response to false
        }
    }

})(current, previous);

From this i was able to get the RITM on which work notes are added within 2 hours 

Kindly mark it correct and helpful if it is applicable.

Thanks,

Raj