Worknotes Updated RITM to Sc Task

siva44
Tera Contributor

I have created 2 Business rules for work notes copied from RITM to sc tasks and Sc tasks to RITM but all is working fine but whenever update the work notes in sc task then Updated in RITM and also affecting on the All attached tasks of RITM

BR:

Table: sc_req_item

When: After Update

condition: worknotes changes
      (function executeRule(current, previous /*null when async*/)

{ var sys_id = current.getUniqueValue();

var scTaskGR = new GlideRecord('sc_task');

scTaskGR.addActiveQuery();

scTaskGR.addQuery('request_item', sys_id);

scTaskGR.query(); if(scTaskGR.hasNext()){

var curWN = current.work_notes.getJournalEntry(1);

while(scTaskGR.next())

{ if(scTaskGR.work_notes.getJournalEntry(1) == '' || curWN.indexOf(scTaskGR.work_notes.getJournalEntry(1)) <0)

{ scTaskGR.work_notes = curWN; scTaskGR.update();

} } }

})(current, previous);

BR:

Table: sc_task

When: After update
condition: worknotes changes

 

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

    // Add your code here
var ritm = new GlideRecord('sc_req_item');

    if(ritm.get(current.request_item)){
        var cw = current.work_notes.getJournalEntry(1);


        if(ritm.work_notes.getJournalEntry(1) == '' || cw.indexOf(ritm.work_notes.getJournalEntry(1)) <0){

            ritm.work_notes = cw;
            ritm.update();
        }
    }
})(current, previous);
1 ACCEPTED SOLUTION

Rupanjani
Giga Guru

Hi @siva44 ,

 

While adding the worknotes from RITM to SCTASK, try to add a string that notifies, from where the worknotes is being added.

 

Added worknotes on RITM: Test notes on RITM.

Add worknotes to SCTASK: Copying worknotes from RITMXXXXX:  Test notes on RITM. (Here, Copying worknotes from RITMXXXXX: will work as an indication).

 

While copying the worknotes to RITM/SCTASK, check the indication string and stop it from adding.

 


Mark the response correct and helpful if the answer assisted your question.

View solution in original post

1 REPLY 1

Rupanjani
Giga Guru

Hi @siva44 ,

 

While adding the worknotes from RITM to SCTASK, try to add a string that notifies, from where the worknotes is being added.

 

Added worknotes on RITM: Test notes on RITM.

Add worknotes to SCTASK: Copying worknotes from RITMXXXXX:  Test notes on RITM. (Here, Copying worknotes from RITMXXXXX: will work as an indication).

 

While copying the worknotes to RITM/SCTASK, check the indication string and stop it from adding.

 


Mark the response correct and helpful if the answer assisted your question.