Flag field on both forms.. after copying of comments make flag on target table false & dont forget to run both BR’s when flag is true.. Two more BR’s to make flag true again after 10 seconds using scheduled job in Business Rule (after/Update/flag comment changes to true / table name)
(function executeRule(current, previous /null when async/) {
// Add your code here
gs.log("Flag value is "+current.u_comment_flag);
if(current.u_comment_flag == true) {
gs.log("Entered into the IF condition ");
//let us schedule a job which makes the flag inactive after 30 secs
var myjob = new GlideRecord('sysauto_script');
myjob.newRecord();
myjob.name = "Auto schedule BR " + current.number;
myjob.active = true;
myjob.run_type = 'once';
var gdt = new GlideDateTime();
gdt.addSeconds(10); //add 10 secs to current date
myjob.run_start = gdt;
myjob.script = "var gr = new GlideRecord('incident');gr.addQuery('sys_id','"+current.sys_id+"');gr.query();if(gr.next()){gr.u_comment_flag=false;gr.update();}";
myjob.insert();
}
})(current, previous);