Passing comments From Task to RITM & RITM to Task

subashds6515
Tera Contributor

Hi All,

 

I have two business rules set up - one for passing comments from a Requested Item (RITM) to a Task, and another for passing comments from a Task to an RITM. 

Two Business rules are active only. Both are the same Condition: current.comment.changes()

1. RITM to Task

if I enter a comment in RITM it will display in the task comment.

2. Task to RITM

if I enter a comment in the task it will display in the RITM comment.

 

Two business rules are triggering at the same time. So that same comment is passing from RITM to task and also from Task to RITM.

 

  • if a comment from RITM to a Task it should not trigger a business rule(Task to RITM).
  • if a comment from Task to a RITM it should not trigger a business rule(RITM to Task).

What is the solution to prevent the repeating comments?

 

Task comment section:

subashds6515_1-1706299066516.png

RITM comment section:

subashds6515_3-1706299154235.png

 

 

 

Thanks,

Subash

8 REPLIES 8

Hi @subashds6515 ,

 

Sorry i just got some different approach can u give that a try maybe u can remove the condition for current.table_name & just keep comment changes n in ur script before update just use gr.setWorkflow(false). This will stop the other BR from executing & only once ur comment will be updated.

 

Thanks,

Danish

 

shyamkumar VK
Kilo Patron

@subashds6515 , try with this and condition would be same as comments changes 

1.  After Insert/Update business rule that runs on RITM table when Comments | changes

    var com = "RITM Comments for " + current.number + " : " + current.comments;
    if(com.indexOf('RITM Comments')>-1 && com.indexOf('Catalog Task comments')==-1)
{
    var cattaskis = new GlideRecord('sc_task');
    cattaskis.addQuery('request_item', current.sys_id);
    cattaskis.query();
        if (cattaskis.next()) {
           cattaskis.comments= "RITM Comments for " + current.number + " : " + current.comments;
           cattaskis.update();
        }
    }

2. After Insert/Update business rule that runs on SC Task table when Comments | changes

    var com = "Catalog Task Comments for " + current.number + " : " + current.comments;
    if(com.indexOf('RITM Comments')>-1 && com.indexOf('Catalog Task comments')>-1)
{
    var ritmis= new GlideRecord('sc_req_item');
    ritmis.addQuery('sys_id', current.request_item);
    ritmis.query();
        if (ritmis.next()) {
           ritmis.comments= "Catalog Task Comments for " + current.number + " : " + current.comments;
           ritmis.update();
        }
    }

https://www.servicenow.com/community/developer-forum/copy-comments-from-ritm-to-task-vice-versa/m-p/...

Regards,

Shyam Kumar 

 

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

DanielCordick
Mega Patron
Mega Patron

You could do a gs.isInteractive() on both business rules as a condition. 

i should have mentioned, for this trick to work, you need to set both business rules to async