How to write a business rule to update values in field when you insert values in another field?

skendy
Tera Expert

Hi,

I am trying to do a simple thing (in project mgmt module):

I am inserting some values in a string field (called 'Owner') and I want that in accordance to this values, some values will fill another field (called 'Department'), AUTOMATICALLY.

I know it should be a business rule, but I'm not having success with this script:

if (current.u_owner=="owner_name")

{

      current.u_lead_bus_sub_dept="department_name";

}

Thank you all for any help,

Skender

1 ACCEPTED SOLUTION

BR Details



Active = true


Insert/Update


Before



Script:


if (current.u_owner.getDisplayValue()=="owner_name")


{


current.u_lead_bus_sub_dept="Any string"+ current.department;


}


-Anurag

View solution in original post

14 REPLIES 14

Can you select the insert and update checkbox to true and select the advanced checkbox too with action as after..



Sent from my android device.


I've tried them all, but it has no effect.


Anytime I flag them and do Update from the form, I see them false again (I have access as the system admin)...


I really do not understand. And I cannot find similar questions in web or communities..



Here is the debug output:



16:18:38.87: Execute before_display business rules on sys_script:Insert Dpt when Owner is Skender associate Depart


16:18:38.88: === Skipping 'Check advanced business rule' on sys_script: Insert Dpt when Owner is Skender associate Depart; condition not satisfied: Filter Condition: advanced=false^conditionISNOTEMPTY^ORscriptISNOTEMPTY^EQ


16:18:38.90: Execute before business rules on sys_template:


16:18:38.90: === Skipping 'SNC Template Query' on sys_template:; condition not satisfied: Condition: gs.isInteractive() && !gs.hasRole("template_editor_global")


The business rule is getting skipped as per the logs .. The condition is getting satisfied .. Is u_owner a string field or a reference field? If a reference field , you need to give the sys id of the user record


Hi Kalai,



Yes, Owner is a reference field (picks the information from Users).


How can I give the sys_id?



Thanks,


Anurag's suggestion should work well