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

can you give it another shot with


gr.setWorkflow(false);


instead of


gr.setWorkflow('false');




//passing Boolean instead of string in the function


-Anurag

no change unfortunately


Hi Anurag,



I need help with this as well. I want to copy comments from task to requested item and from requested item to other catalogue tasks in the workflow.



It is before BR and also tried using gr.setWorkflow(false);. This copies comments from task to requested item but stops copying to other tasks.



Thanks,


Hema


are you using different BR's to copy the worknotes ??


-Anurag

Hi Anurag,



Yes I am using different business rules.



One to copy comments from Task to requested item and other rule to copy from requested item to task.



Pass comments to Requested item



Before BR on update


addCommentToReqItem();


function addCommentToReqItem()


{


if (current.sys_id == '')


return;


var gr = new GlideRecord('sc_req_item');


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


gr.query();


while (gr.next()) {


gr.comments = current.comments;


//gr.setWorkflow(false);


gr.update();


}


}



Pass comments to Task



addCommentToTasks();


function addCommentToTasks() {


if (current.sys_id == '')


return;


var gr = new GlideRecord('sc_task');


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


gr.query();


while (gr.next()) {


gr.comments = current.comments;


//gr.setWorkflow(false);


gr.update();


}


}



Thanks,


Hema