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

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

HI Skender,



You can use the on change client script if you want the other field to be populated as soon as the field is changed. Also I am assuming that you are using the before business rule here.


Thank you Pradeep,



Could you be more precise? I 'm applying the business to the pm_project table.


The operation is only an kind of association: anytime I insert or update the Owner field (with a name), the field Department is being populated automatically, because of a (business) rule I set.



But I do not know the flags and options to choose (insert or update or both) and what to say to Condition,   When and Actions?




Thank you again,


Skender  


Hey Skender,



If I understand your requirement correctly here, You want the user department to be autopopulated as and when you enter the username in the owner(string field). Please confirm.


If you can replicated on what you want in any demo instance that will be helpful. I can take a look and help you.


Yes it is correct.


Here is the illustration:



business_rule.png