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();
}

View solution in original post

8 REPLIES 8

Musab Rasheed
Kilo Patron

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


        }

Voona Rohila
Tera Patron

Hi karishma

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

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