copy work notes to short description form one catalog task to another catalog task

karishmashaik
Kilo Expert

Hi all,

I have a requirement, copy the work notes content to short description form one catalog task to another catalog task ,copy the work notes to short description form TASK1 to TASK2 and to TASK3.

 

please help me on this 

 

Thanks,

karishma.

1 ACCEPTED SOLUTION

Hi 

above code is to copy worknotes to another task wornotes.

try below code

 

var grScTask = new GlideRecord('sc_task');
grScTask.addEncodedQuery("request_item=" + current.request_item +"^sys_id!=" + current.sys_id);
grScTask.query();
while (grScTask.next()) {
    grScTask.short_description = "Worknotes from " + current.number + " : " + current.work_notes.getJournalEntry(1);
    grScTask.update();
}

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

View solution in original post

8 REPLIES 8

Musab Rasheed
Tera Sage
Tera Sage

Hi,

Please try this, Only doubt is it is better to copy in description rather than in Short description as short description has character limit. Mark my answer as correct or hit like based on impact.

var gr = new GlideRecord('sc_task');


        gr.addQuery('parent', current.parent.sys_id); // Get an sc_task with the same parent as the current one



        gr.query();


        if (gr.next()) {


                  current.description = gr.work_notes.getJournalEntry(-1); // Need to set the current comments not the GlideRecords


        }
Please hit like and mark my response as correct if that helps
Regards,
Musab

Voona Rohila
Kilo Patron
Kilo Patron

Hi karishma

when do you want to copy the worknotes content to short description?


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Hi Rohila Voona,

 

when I close complete catalog task's, then work notes content should copy to next catalog task's description .

for example ,

Task 1 to Task 2 to Task 3,

please Help Me on this,

Karishma .

Write a before update BR on catalog task table

filter - state changesto complete

code:

var grScTask = new GlideRecord('sc_task');
grScTask.addEncodedQuery("request_item=" + current.request_item +"^sys_id!=" + current.sys_id);
grScTask.query();
while (grScTask.next()) {
    grScTask.work_notes = "Worknotes from " + current.number + " : " + current.work_notes.getJournalEntry(1);
    grScTask.update();
}

 

current.work_notes.getJournalEntry(-1);    // -1 for all the work notes value , 1 for latest work notes value


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP