function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
HeeseHeese 

Help creating a trigger to update Account.BillingState

Hi all,

 

I need a bit of some help creating a trigger.   Contacts and accounts are being created using the API.  Upon insert a contact and an account are created with the following data:

 

Account Owner (defaulting to the api account)

Account Record Type (In this case "Enterprise'")

Account Name

 

Contact Owner (defaulting to the api account)

Contact Name

Contact MailingState

Contact MailingCity

 

What I need to do is create a trigger to perform the following.  After insert, check if Account BillingState, AccountBillingCity are null and Account Record Type is named  "Enterprise" or the 15digitid.  If so, populate AccountBillingState with the Contact Mailing State and populate AccountBillingCity with the ContactMailing City

 

I hope this makes sense.  Thank you in advance.  

srikanth123srikanth123

trigger copyAddress on Contact (after insert)

{

//code to pull the account details related to contact

....

//check if the account details satisfy your conditions

...

//if conditions are satisfied then copy contact address to account

}

 

let me know if you need any other info

HeeseHeese

That sounds right, thank you.  Is there a recommended resource or perhaps some existing code to help me get started?  Thank you