work notes duplicating when copying between task and item

chrisp1
Mega Sage

Hi,

I have a requirement to have comments and work notes copied from items to task and vice-versa, so I have created 2 business rules to do this (as below) - the issue is that i get duplicate entires (eg a work note added to the item is copied to the task, but then as the work notes on teh task have changed this is then copied back to the item again)

Is there a better way of doing this which will avoid the duplication?

( i have tried adding the request item comments and work notes to the task form, but there does not seem to be the option to go the other way, and this still contains duplications)

thanks in advance

- before update on sc_req_item (when add comm/wn change)

var gr = new GlideRecord('sc_task');

gr.addQuery('request_item',current.sys_id);

gr.query();

while(gr.next()){

gr.comments = current.comments;

gr.work_notes = current.work_notes;

gr.update();

}

- before update on sc_task (when wn change)

var gr = new GlideRecord('sc_req_item');

gr.get(current.request_item);

gr.work_notes = current.work_notes;

gr.update();

11 REPLIES 11

Anurag Tripathi
Mega Patron
Mega Patron

Hi Chris,



Make both these Business rules as after with a large order value...order =900



- after update on sc_req_item (when add comm/wn change)


var gr = new GlideRecord('sc_task');


gr.addQuery('request_item',current.sys_id);


gr.setWorkflow('false');


gr.query();


while(gr.next()){


gr.comments = current.comments;


gr.work_notes = current.work_notes;


gr.update();


}



- after update on sc_task (when wn change)


var gr = new GlideRecord('sc_req_item');


gr.setWorkflow('false');


gr.get(current.request_item);


gr.work_notes = current.work_notes;


gr.update();


-Anurag

Fathah
Giga Contributor

try to use gr.setWorkflow(false); before gr.update(); statement


i suggested that only


-Anurag

thanks for the suggestions


gr.setWorkflow('false'); doesn't seem to make any difference


setting to after 900 stops it copying it over at all