copy from inciden task 'close notes' to parent incident worknotes

tushar_ghadage
Tera Contributor

Hi All , 

I am trying to copy close notes from incident task (when its close complete) to parent incident record in worknotes.

 

here is the before update with condition close notes changes business rule is used: 

 

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

    // Add your code here
    var lastWorkNote = current.close_notes.getJournalEntry(-1);

    var parentInc = new GlideRecord('incident');
    parentInc.addQuery('sys_id', current.parent_incident);
    parentInc.query();

    if (parentInc.next()) {
        parentInc.work_notes = lastWorkNote;
        parentInc.update();
    }

})(current, previous);
 
but its not getting copied as expected , please help me out !!
17 REPLIES 17

Hi @_Gaurav , 

i tried replicating the same but it did not work , below are my config and test results :

 

Screenshot (20).pngScreenshot (21).png

test results :

Screenshot (15).pngScreenshot (16).png

Hi @tushar_ghadage 
For testing purpose, can you please remove the condition from the BR and just run on the UPDATE and try?
Also, can you replicate with my given code please?

_Gaurav_0-1743603474679.png_Gaurav_1-1743603503406.png

Here is the screenshot of my configuration.

Please mark this as a solution and helpful if this resolves your query.

Thanks!

Hi @tushar_ghadage ,

 

Are you putting some values in your close notes ? Also in your snip you BR in inactive. Make it active. 

 

RohitSingh_1-1743606123060.png

 

RohitSingh_2-1743606154144.png

 

Also you can try my code which I have mentioned earlier also.

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

	// Add your code here

	var close_info = current.close_notes.toString();   // get the value of close notes
	var gr_inc = new GlideRecord("incident");
	gr_inc.get("sys_id",current.incident);
	gr_inc.work_notes = close_info;
	gr_inc.update();

	

})(current, previous);

 

If my response helped, please hit the Thumb Icon and accept the solution so that it benefits future readers.

 

Regards,
Rohit

Hi @tushar_ghadage ,

 

Did you check my response?

 

In your snip your BR is not active.

If my response helped, then accept the solution and hit the thumbs up, so that it benefits the future reader and also me for your efforts towards the community.

 

Regards,

Rohit

 

 

 

 

Hi @tushar_ghadage ,

Looks like you are updating the work notes of the incident task
you are suppose to update the close notes right?

what do you want to copy? incidents are close notes or work notes from incident task to incident

if it is close notes you can have follow below

ChaitanyaILCR_2-1743606363987.png

ChaitanyaILCR_3-1743606380415.png

 

 

 

if it is work notes follow below

ChaitanyaILCR_0-1743606259677.png

ChaitanyaILCR_1-1743606291205.png

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya