+ Start a Discussion
Kevin Dal PortoKevin Dal Porto 

Update Lookup field with trigger or Workflow

While viewing a standard Contact object, I press new to create a new record in a custom related list object.  The New Custom object record populates the Contact lookup field, but does not populate the Account Lookup field.  I need to populate the Account Lookup field.  What is the best way to accomplish this knowing that I plan to create a managed package which would proclude any use of URL hacking or other non-Salesforce accepted practices?
Best Answer chosen by Kevin Dal Porto
Phil WeinmeisterPhil Weinmeister
Hi Kevin,

I was looking into this. If you want to actually see the Account field populated immediately, I believe the only options are URL hacking (via custom button) or combining a custom VF page and a custom button. The latter would be an acceptable Salesforce practice. You could create a custom page just for this scenario - creating the object as a child of a Contact from the Contact related list and automatically populate the Account based on the populated Contact record.

A workflow wouldn't really work, because you can't set a lookup dynamically within workflow rules.

What do you think?

Thanks,
Phil

All Answers

Deepak Kumar ShyoranDeepak Kumar Shyoran
You can achieve this for native pages but all you can do is can create a workflow or trigger which will populate the Account field and when you view that newly created records you will see that Account fields to be populated.
Phil WeinmeisterPhil Weinmeister
Hi Kevin,

I was looking into this. If you want to actually see the Account field populated immediately, I believe the only options are URL hacking (via custom button) or combining a custom VF page and a custom button. The latter would be an acceptable Salesforce practice. You could create a custom page just for this scenario - creating the object as a child of a Contact from the Contact related list and automatically populate the Account based on the populated Contact record.

A workflow wouldn't really work, because you can't set a lookup dynamically within workflow rules.

What do you think?

Thanks,
Phil
This was selected as the best answer
Kevin Dal PortoKevin Dal Porto
Thanks for your response. Can’t use URL hack because the package will be managed. VF page seems overkill. Shouldn’t I be able to use a Apex Trigger?