- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2017 04:12 AM
Hi All ,
I have a requirement for inserting records in custom table whenever there is a a new record created in Incident[incident] table .
I have tried writing Async business rules for "update" and its working as expected . But the same business rule is not working when I Use "Async" and "Insert" .
Will Async Business rule not work for "Insert" operation ?
Regards,
Ankitha
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-31-2017 09:54 PM
Hi All ,
The script was running first and then the SLA was getting in created in task_sla table.Tried adding gs.SLEEP and it is collecting insertion data now.
Regards,
Ankitha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2017 04:15 AM
can you please share your script running in async BR?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2017 04:18 AM
Hi Sushant ,
PFB the below code
(function executeRule(current, previous /*null when async*/) {
var task_sla = new GlideRecord('task_sla');
task_sla.addQuery('task.number',current.number);
task_sla.addActiveQuery();
task_sla.query();
while (task_sla.next()){
var metricdef = new GlideRecord('custom_table');
metricdef.initialize();
metricdef.setValue("u_table_name", "task_sla");
metricdef.setValue("u_assignment_group",current.assignment_group );
metricdef.setValue("u_priority",current.priority);
metricdef.setValue("u_category",current.u_cs_category);
metricdef.setValue("u_ci",current.cmdb_ci);
metricdef.insert();
}
})(current, previous);
Regards,
Ankitha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2017 04:36 AM
script looks good to me.
Can you please turn on the debugger and put some log statement in your script?
in this way we will come to know if your Async BR is getting executed or not ? if executed till what point it reached for insert in custom table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2017 06:00 AM
I think the 2010 SLA engine uses an async business rule against task to create/update SLA records. If that's the case, your script may not find the SLA because it hasn't been created yet. Check out this property on your instance: com.snc.sla.engine.version
You might try increasing the order of your Business Rule. The above mentioned SLA runs at order 101 I believe, so yours would need to be > 101.