Override he value of Parent field in task table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2024 09:47 AM
Hi All,
I am facing a issue trying to update 'parent' filed in the Task table but the reference field update is not working via the business rule.
The ticket I have is using the default parent child linkage but in case or my ticket type 'Requested Items', I only need cases to be allowed in the parent field. As the parent child relationship between cases and requested items only needs a change, I created a new fields called u_case that will store the value of the case id when the linkage happens with the case via a business rule.
(function executeRule(current, previous /*null when async*/ ) {
if (!current.parent.nil() && current.parent.sys_class_name == 'sn_customerservice_case') {
current.u_case = current.parent;
current.update();
}
})(current, previous);
The update in u_case here is working fine but if someone links another kind of ticket with the requested item via the related records option, parent field gets overridden and the linkage with cases beak. To handle this case, I added below condition in the business rule:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2024 12:01 PM
Hi, unfortunately your post doesn't make your issue or configuration very clear.
What are the results of your debugging? Have you enabled BR debugging to confirm that the BR's run when expected? Have you added any logging to your BR(s) to see if the value is populated, but then overwritten or removed by another BR , script or flow\workflow? Have you enabled ACL debug and confirmed that the soruce record field can be read, and the target record field can be written?
Is this BR a before or after BR?
Also 'current.update()' is not best practice and potentially produces an update loop which could also be cause of your issue.
Recommended practices avoiding to use current.update() in Business Rules - Support and Troubleshooti...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2024 03:44 AM
Thanks Tony,
I did addinfomessages into my condition and can confirm that the BR is called. I am calling the BR after update.
I tried updating the parent field with different ticket number manually as well and the logic in the BR is working as expected so this suggests that the field is getting overridden somehow when the linkage happens by adding bRITM into the related lists of another ticket.
Any ideas on how can I identify what's overriding the value or a way I can prioritize this BR?
Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2024 06:49 AM
Marking the BR as async has resolved the problem.