Set Primary Contact of an Account as Contact of Case

zachbarr
Mega Contributor

I have a requirement that when an Account is added to a Case, the Primary Contact of that Account is populated in the Contact field of the Case. 

 

I know I need a Business Rule -- but do not know where to start from there.

 

any help is appreciated.

 

thanks,

1 ACCEPTED SOLUTION

Joel Dias
Kilo Sage

Hello,

You can use a business rule with the following condition and script:

find_real_file.png

find_real_file.png

 

Keep in mind that the business rule will only fire when the record is saved.
Also depending on your requirements you may need to handle the cases where there is no primary contact, etc.

View solution in original post

6 REPLIES 6

zachbarr
Mega Contributor

Hi Joeldias,

Here is the code i have for the Client Script and Script Include, but it still is not populating. Any ideas on where I'm going wrong?

find_real_file.png

find_real_file.png

I didn't check everything in detail, but I think there are a few issues with the script include.

The primary customer info is in the account table so you should the data from there:

var account = new GlideRecord("customer_account");
account.get(this.getParameter("sysparm_userID");
var user = account.contact;

Also, for AJAX, I think it is best practice to return the sys_id and display value (getDisplayValue) so you can set both on the client and avoid a round trip when you set the sys_id to the field.

I didn't try the code yet so no garanties.