You need to sign in to do that
Don't have an account?
I am new to Salesforce.com
I need Trigger Example
I need Trigger example... When ever u entered city name in Account object that will automatically update on Contact object by using trigger i need example code.
Thanks,
SFDC_Learner
Here is the trigger for you, Hope it helps you in understanding and writing the triggers next time :)
All Answers
Before we get into the trigger sample code, are you sure you want this trigger? By setting addresses for all Contacts for an Account to the same City (or other fields) as the Account, you are preventing the possibility that a Contact might have a different address than the Account. Generally, the Account has a BillingAddress and a MailingAddress; but each Contact has its own address info.
When creating a trigger in Salesforce, you need to decide whether you want actions to occur before or after, as in before insert, before update, before delete versus after insert, after update, after delete.
The Apex documentation actually has a great article on this called Apex Trigger: Context Variable Considerations.
For instance, if you’re getting an error message
It may be due to a code segment like this:
This is because, specifically in an after update, when attempting to change fields using Trigger.New, this is “[n]ot allowed. A runtime error is thrown, as trigger.new is already saved.”
Don't forget to give kudos ,if this reply helps you.
Why do you need a Trigger for this?
Hi Sharma
please provide example for this...
Here is the trigger for you, Hope it helps you in understanding and writing the triggers next time :)