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

rammohanraomadd
Kilo Guru

Hi,

 

Please create the below script as BR with below details:

 

When : before Insert/Update

Script:

 

var acc = current.account;
var cc = new GlideRecord("customer_contact");
cc.addEncodedQuery("account=" + acc + "^contact_type=primary");//Replace the code with the field and value which mark the contact as prmiary
cc.query();
if(cc.next())
{
current.contact = cc.sys_id;
}

 

 

Regards,

Ram M

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.

Thank you! This worked great, but yes i would like the Contact to show as soon as i pick an Account. Would I need to use a Client Script then. I read that because its a scoped app i would need to use GlideAjax?

 

thanks,

I don't know if you must use an ajax call because you are in a scoped app but it is a best practice anyway to have a responsive interface.

For the cases, you may need to have Business Rule + client script.

The Client script to have the value set immediately when the account is set using the fulfiller interface and the Business Rule for the other cases (service portal/service catalog, list editing).