Override he value of Parent field in task table

Rahul24
Giga Contributor

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:

   
if (!current.parent.nil() && !current.u_last_linked_case.nil() && current.parent.sys_class_name != 'sn_customerservice_case') {
        current.parent = current.u_last_linked_case;
        current.update();
 }
 
but this business rule is not able to update the 'parent' field.
 
Is this a restriction on the field that is blocking the update on parent field? 
 
Thanks,
Rahul Rai
3 REPLIES 3

Tony Chatfield1
Kilo Patron

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...

 

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

Rahul24
Giga Contributor

Marking the BR as async has resolved the problem.