how to auto populate the cost center field value from caller/user to incident form using the business rule

Naresh44
Giga Contributor

Hi all,

I tried auto populating the 'cost center' field value from users table,  using the getReference method in business rule for incident form, but it didn't worked at all.

Please help me in retrieving the value of the cost center field value in the incident form

 

1 ACCEPTED SOLUTION

Hi Naresh,

 

As suggested by Ankur above won't work in business rule as g_form.getReference() are client specific side options to be used.

Try using below business rule that runs After Insert on required table & make sure you have correct field name passed.

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    current.location = current.caller_id.location;

    current.cost_center = current.caller_id.cost_center;

    current.state = current.caller_id.state;

    current.city = current.caller_id.city;

    current.country = current.caller_id.country;
	
	current.update();

})(current, previous);

View solution in original post

25 REPLIES 25

Hi Ankur,

Thanks for your response,

Just now tried the dotwalking method in BR ------state/province, street and cost center fields are not autopopulating.

Please help me.

Thanks & regards

Naresh Uppu

Naresh, your script with getReference is correct but that will not work in business rule because that is a client side code.

Just copy thta script to on change client script which should run on change of caller id


Raghav
MVP 2023

Yes true.

But in my case I must use only business rule.

 

Try below in BR

current.location =current.caller_id.location; current.cost_center = current.caller_id.department.cost_center; current.state = current.caller_id.location.state; current.city = current.caller_id.location.city; current.country = current.caller_id.location.country; current.update();


Raghav
MVP 2023

Thank you for the reponse.

The BR code is working fine for every caller except for the ABRAHAM LINCOLN --- i.e country field value is not populating on the incident form.

May I know why?

Thanks & Regards

Naresh Uppu