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
george_dewaltgeorge_dewalt 

2 Triggers


Hi,

I just created a new developer account,
but haven't done anything with it just yet.

I was wondering how I were to complete
the following tasks:

1.) Make a trigger to execute every time
      that an Account record is created,
      so that it will create a new Contact record,
      with some fields in it and some values for them?

      NOTE : This newly created Contact record
                    should be connected to the Account record.



2.) Make a second trigger -- perhaps for the
     same Account record?   I'm not sure...

     I heard there's supposed to be a
     field called "Parent Account", for
     Account records.

      Is it possible, then, to code a trigger
      that will execute upon a field's value change

      in a "Parent" record, where that trigger (or code)

      will update the equivalent field in ALL
      "child" accounts as well?

 

       For example, let's say the "Parent" record

       has a "phone number" field;

 

       How should I get the trigger - whenever

       a NEW phone number (value) is entered,

       to update the "phone number" field at

       ALL of the "child" accounts that specify the "main"

       Account as their "Parent Account"?

 

 

Thanks in advance
George



vishal@forcevishal@force
Hello, Assuming that this is your first coding task in Salesforce, I'll suggest you to go through the Salesforce Trigger document here. What you mainly need to know is : 1. What is a trigger? 2. Dfiferent events like before insert, after insert, before update, after update, etc. 3. When to use which event? 4. How to determine which object your trigger should be on? Once you have some idea on it, you can try writing the trigger. Any issues, let the community know!
george_dewaltgeorge_dewalt

Thanks Vishal :)

 

I'm going to read the documentation now.