function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RuleyRuley 

Default Value on Lookup field

We have a new field on the Opportunity object called "Purchasing Account" (Purchasing_Account__c). The data type is Lookup on the Account object. We needed this because we wanted to track both who the opportunity is for as well as who is going to be paying for the opportunity, usually it is the same, but sometimes it is different and to automatically flow orders into our ERP system and invoice the correct customer this field made the most sense.

 

What I want to do now is make it as easy as possible for users by defaulting the value in "Purchasing Account" to be the same as "Account Name" which is the standard lookup. 

 

I can do it with a trigger, if blank fill in same value as in Account Name, but I was wondering if there is an easier way to do it.

Shashikant SharmaShashikant Sharma

You can also do it using a workflow rule

 

Rule Criteria : Every time record is created or Updated

Condition Criteria : Purchasing_Account__c lookup is null and Standard Account not equal to null

 

Add Work Action a Field Update :  Field to Update Purchasing_Account__c  and in Specify New Field Value Select Standard Lookup field for Account

goabhigogoabhigo

I am afraid that you can only do it either with trigger or VF page and controller. Workflow cannot update lookup field.