You need to sign in to do that
Don't have an account?
cmctam
writing triggers
hi
haven't a clue how to figure out how to write triggers. none of the examples have enuff explanation to get me going.
i want to write a trigger that does the following:
the trigger needs to fire on update of contacts.Account
it would have to look up the accounts.organization_code__c where accounts.Name=contacts.Account
and make contact.org_code__c =account.organization_code__c
and make contact.org_code__c =account.organization_code__c
any takers :)
thanks
tammy
With the information you have given us it can probably be done with either formula fields or workflow rule. The workflow rule can be triggered when the Account associated with a Contact changes, or other criteria, and will pulll the Account.organization_code__c and place it in the field on your Contacts. If you need this done for a specific reason with Apex then it will take more work to process and require the testing before it can be done within a production instance. If you want something like this built then please email me or go to my site to contact me.
private Contact[] newContact= Trigger.new;
private Contact[] oldContact= Trigger.old
//creates a variable reference to the object that fired the tirgger
{
for (Account a : [select organization_code__c
newContact.org_code__c=a.organization_code__c
}
update newContact
}