Copy comments from RITM to Task & vice versa.

Naveen87
Tera Guru

Hey Experts,

I'm trying in PDI, I want to fetch additional comments & work notes from RITM to Task & vice-versa.
Please do suggest a simple script with explanation.

Also on which table(BR should be written) also under BR which table should Glided is still a confusion for me.

Under RITM I dont see worknotes tab.

 

find_real_file.png

Under Task, I dont see addition comments.

Please suggest .

find_real_file.png

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

You can try below

1.  After Insert/Update business rule that runs on RITM table when Comments | changes

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

    var com = "RITM Comments for " + current.number + " : " + current.comments;
    if(com.indexOf('RITM Comments')>-1 && com.indexOf('Catalog Task comments')==-1)
{
    var cattaskis = new GlideRecord('sc_task');
    cattaskis.addQuery('request_item', current.sys_id);
    cattaskis.query();
        if (cattaskis.next()) {
           cattaskis.comments= "RITM Comments for " + current.number + " : " + current.comments;
           cattaskis.update();
        }
    }
})(current, previous);

 

2. After Insert/Update business rule that runs on SC Task table when Comments | changes

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

    var com = "Catalog Task Comments for " + current.number + " : " + current.comments;
    if(com.indexOf('RITM Comments')>-1 && com.indexOf('Catalog Task comments')>-1)
{
    var ritmis= new GlideRecord('sc_req_item');
    ritmis.addQuery('sys_id', current.request_item);
    ritmis.query();
        if (ritmis.next()) {
           ritmis.comments= "Catalog Task Comments for " + current.number + " : " + current.comments;
           ritmis.update();
        }
    }
})(current, previous);

To make it understand what we do is as below.

1. When comments are copied from RITM to Catalog task we add static text 'RITM comments'. Once done we check it in IF statement for the keyword. So, if keyword has 'RITM comments' & does not have 'Catalog Task' as keyword. Only then we will copy it to Catalog Task's comments field. 

2. So, now when Catalog Task business rule that copies comments to RITM is processed it will check for keyword that has 'Catalog Task comments' & does not have 'RITM comments' thus ensuring the comments are not copied back & forth thus avoiding duplication.

 

'Under RITM I dont see worknotes tab.' - It seems you are checking on Activity stream & not Form layout or design. If you want to add it to activity stream click on the Configure available fields & move the Worknotes from Available to Selected area.

View solution in original post

7 REPLIES 7

How can I modify the script to exclude copying work notes from the RITM to the SC TASK?

I attempted to implement a similar solution and it did not work for me (in Washington DC). The resulting Comment on the journal blank string from after BR.jpg

 

Here is what did work:

2. BEFORE Insert/Update business rule that runs on SC Task table when Comments | change

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

    var taskComments = current.comments;
    var taskNumber = current.number;

    var com = "Update from " + taskNumber + " : " + taskComments;

    var ritmGR = new GlideRecord('sc_req_item');
    ritmGR.addQuery('sys_id', current.request_item);
    ritmGR.query();
    if (ritmGR.next()) {
        ritmGR.comments = com;
        ritmGR.update();
    }


})(current, previous);

 Note that in the AFTER business rule, the journal field is empty. You must capture it in a Before business rule in order for it to not be a blank string. 

srinithi Venkat
Tera Contributor

Same Requirements but little different. When users add comments in the portal that is usually added to the main ticket but here " the comments are copied to Task also (In case we have Task under the ticket).
How to achieve this? @Jaspal Singh