+ Start a Discussion
pradsy90pradsy90 

Automatically Determine Account from Contact

Hi -

 

I have created a custom object called Reservation which has the Account and the Contact fields. They are defined as look up fields.

 

When I create a new Reservation I would like the Account field to be determined based on the Contact I choose.

 

How can I do this on the default creation page view that SalesForce provides for a custom object.

 

Do I have to use a VLOOKUP Function? If yes, where?

 

A code snippet would be appreciated.

 

Thanks in advance for your time.

 

Regards,

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,

 

You can do this through writing a trigger on your custom object or  you can create a formula field(Return type Text) on Custom Object in which you have to assign the value  as Contact__r.Account.Name and after saving a record your formula filed contain Account name which is associated with that contact which you have selected. You can’t update lookup field through workflow so you have to write a trigger in that case.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

All Answers

Navatar_DbSupNavatar_DbSup

Hi,

 

You can do this through writing a trigger on your custom object or  you can create a formula field(Return type Text) on Custom Object in which you have to assign the value  as Contact__r.Account.Name and after saving a record your formula filed contain Account name which is associated with that contact which you have selected. You can’t update lookup field through workflow so you have to write a trigger in that case.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

This was selected as the best answer
pradsy90pradsy90

Hi -

 

Thanks for your reply. Yes, this helped and worked.

 

I was able to achieve what I wanted using the Formula Field.

 

I will try placing the triggers on the custom object as well.

 

Regards,