You need to sign in to do that
Don't have an account?

Autopopulate a field when another is filled in and saved
I want to write a trigger that will auto populate a date field when another date field from another object is filled in. One field is from a custom object the other from a standard Contract object. The account name that is attached to both objects has to match so that the correct date is passed into the field that I have created.
So, I want to take a date from the contract object and put it in a field in the custom object, where their accounts match. There is a little hiccup in this that I do not know how to handle. in the standard Contract object the Account field is a standard lookup field. But in the custom object the the Account Name field is a custom field that has a master detail relationship to Account. - how do I deal with that? I just want to make sure that the accounts being referenced in the two different objects are the same Account.
Does anyone have an idea of how to start this trigger? or even pseudo code would be helpful because I cannot wrap my head around this right now.
Depending on your requirements, you may be able to do this with one or more formula fields rather than a trigger, which will be much simpler.
select from your custom object when the name matches and save that field to match.
You can probably get it to only update the field if it changed due to the update.
You'll also probably need to get it to itterate through the individual custom objects which you can do by selecting to an array. That should deal with you probably having a many to one relationship.
That is if I'm reading the situation correction. I'm guessing you want for the date to update when the account name selected corresponds with the account name in the project yeh? Something to consider will be, what if you have several contracts related to the same account object.
You have any experience in testing triggers?
I'm stuck on mine
Message Edited by Nonick on 11-20-2008 04:43 PM
Thanks.