worknotes not updating via business rule

ronaldanand
Tera Contributor

Hi All

When ever the User get inactive i want to update the incident worknotes please reassign the ticket to some one.

I used follwing business rule in SYS_USER table and AFTER / UPDATE condtion.

But i not able update the worknots. Please some one help me to fix this issue.

find_real_file.png

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

var rec=new GlideRecord('incident');
rec.addQuery('assigned_to',current.sys_id);
rec.addQuery('active',true);  
rec.addQuery('state','!=',6);   /
rec.query();
while(rec.next()){
     rec.assigned_to = '';
     rec.work_notes = "Manual Worknotes";
  rec.setWorkflow(false);  
  rec.autoSysFields(false);      rec.update();
 
}
   
})(current, previous);

1 ACCEPTED SOLUTION

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,

So when we write a setWorkflow(false) it will not update the journal entry table and audit tables. Because no business rule will run and then hence worknotes will not get updated in activity log and in respective tables.


Thanks,
Ashutosh

View solution in original post

9 REPLIES 9

VigneshMC
Mega Sage

This is because of " rec.setWorkflow(false);  ", as this will prevent BR running which used to run because of this action.

BR needs to run to push the work notes update to the activity log

Please brief more .. Am not clear

 

AbhishekGardade
Giga Sage

Try this: 

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

var rec=new GlideRecord('incident');
rec.addQuery('assigned_to',current.sys_id);
rec.addQuery('active',true);  
rec.addQuery('state','!=',6);   /
rec.query();
while(rec.next()){
     rec.assigned_to = '';
  rec['work_notes'].setJournalEntry("Manual Worknotes");
  rec.setWorkflow(false);  
  rec.autoSysFields(false);      rec.update();
 
}
   
})(current, previous);

Please mark as Correct Answer and Helpful, if applicable.
Thanks!
Abhishek Gardade
Hexaware Technologies

Thank you,
Abhishek Gardade