Copy Work Notes from Task --> RITM and Vice Versa

RAHUL Khanna1
Mega Guru

Hello Guys, 

I am looking for a  robust solution solution for the following requirement.

REQ0001
----RITM001
--------TASK0001
--------TASK0002
--------TASK0003
--------TASK0004
----RITM002
--------TASK0005
--------TASK0006
--------TASK0007
--------TASK0008

Requirement: There is a posibily that the fulfiller can changes the Variables in the variable editor, or can change the work notest or can changes both: So the requirement is propagete the chagnes through out.

 

Exe: if we enter test notes-1 in TASK-1 + Variable Chagne, I should see the same work notes in RITM, Task-2, Task, 3 , Task-4 , somewhat like this 

From TASK001: 

1) Variable_name1: <Changed Value>

2) Work Notest: test notes-1

Currrent Approach : I have created a Before BR on sc_task Table, for which I was able to capture the changes of the variable and then append the current work notes and then concatenation of two string and setting it to current work notes.

Next I am lookign for a better approach, I understand that I need to create a after busines rule ....and then set work flow false to avoid to avoid the looping also same needs to applied on the RITM table.

SO looking for a better approach, also I am not able to access the cuurent.worknots or previous worknotes in after business rule , but to my surprice ....i could see current.work_notes.changes() is resulting as true.

Can some  body try to provide a simple approach.

 

 

        

 

 

 

 

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Rahul,

So when either any variable changes or work notes changes the BR should trigger.

If that is the case then you would require after update BR on sc_task to update the RITM and the corresponding other tasks for that RITM other than the current one.

In after BR as you said you are not able to get the previous value; in that case you can query sys_journal_field for that field and pick the latest and the previous value.

You can also try to use flow designer approach but I am not sure whether it would detect the variable change or not.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

As of, we are looking to achieve from BR's only as we have already existing after BR , we want to accomodate in to it....and I am able to extract journal entries by getJournal(1) method....but only confused that we need to write before and after BR, on both RITM and sc_task and also notification part should also be taken care...in between we are using set work flow false aslso .... 

Alp Utku
Mega Sage

You need to write after business rule run on insert and updates. The business rule should be written on sc_req_item table when additional comments changes (as condition)

 

var usrtext = "RITM Comment= "+current.comments.getJournalEntry(1); //get latest update
	
	var cmn = new GlideRecord('sc_task');
	cmn.addQuery('parent', current.sys_id);
	cmn.orderBy('order');
	cmn.query();
	
	while (cmn.next()) {
		cmn.work_notes = usrtext; //copy RITM comments to tasks
		cmn.update();
	}

 

 

But how abt from task to RITM---and also as I mentioned I need to populate the change of variables as well....