Case Activity Log getting updated Multiple times
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2018 03:20 AM
Hi Team,
For me the activity log updating multiple times Due to Business Rules which are running on case one was for Insert and other one was for Update.
Whenever a record was Inserted one update was logging and after that at the time of after SLA attached to the case it was logging the activity log 2nd time,also whenever priority changes on the form the Activity log was getting updated twice, one Update was for Priority change and the other one was for Due Date Change (Whenever Priority changes Due date also will change).
We Can't Drop the BR's, as there were dependencies on the BR"s.
Can Anyone Suggest Any other Way to Resolve this Scenario.
Thanks,
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2018 03:59 AM
Hi,
Can you check if you have setForceUpdate(true); in any of your BR running on this table.
This can upadte the field forcefully, thus updating the activity logs as well.
Thanks
Gaurav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2018 04:51 AM
Hi Gaurav,
There was nothing like setForceUpdate(true) on the BR's.
Insert BR:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var sla = new GlideRecord('task_sla');
sla.addQuery('task', current.getUniqueValue());
sla.addQuery('active',"true");
sla.addQuery('sla.u_fixed', "true");
sla.orderByDesc('planned_end_time');
sla.query();
if(sla.next())
{
current.due_date = sla.planned_end_time;
current.autoSysFields(false);
//current.setWorkflow(false);
current.update();
}
})(current, previous);
Update BR:
(function executeRule(current, previous /*null when async*/) {
//gs.addInfoMessage("isnide BR for due date chnage");
// Add your code here
var sla = new GlideRecord('task_sla');
sla.addQuery('task', current.getUniqueValue());
sla.addQuery('active',"true");
sla.addQuery('sla.u_fixed', "true");
sla.orderByDesc('planned_end_time');
sla.query();
if(sla.next())
{
current.due_date = sla.planned_end_time;
current.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2018 06:39 AM
Hi Raj,
Instead of using current.update in both insert and update BR, please query the incident table and update the due date field.
Never use current.update in a Business Rule
You can try the below script.
(function executeRule(current, previous /*null when async*/) {
var sla = new GlideRecord('task_sla');
sla.addQuery('task', current.getUniqueValue());
sla.addQuery('active',"true");
sla.addQuery('sla.u_fixed', "true");
sla.orderByDesc('planned_end_time');
sla.query();
if(sla.next())
{
var inc = new GlideRecord('incident');
inc.get('sys_id',current.sys_id);
inc.due_date= sla.planned_end_time;
inc.autoSysFields(false);
inc.setWorkflow(false);
inc.update();
}
})(current, previous);
I was wondering why do you have two different BR while you can do both operations in one itself.
Thanks
Gaurav
PS: Please mark the response correct/helpful based on the impact.