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

Auto Populate lookup fields based on another lookup field value
Hi,
I have two objects A & B. I have 4 lookup fields on object A with object B. When I select lookup field value in first field; I want all the other 3 lookup fields to be autopopulated. (All the three are user fields on object B which are looked up in object A). How to accomplish this? Thanks in advance!
I have two objects A & B. I have 4 lookup fields on object A with object B. When I select lookup field value in first field; I want all the other 3 lookup fields to be autopopulated. (All the three are user fields on object B which are looked up in object A). How to accomplish this? Thanks in advance!
If not you can write your own apex trigger for this.
<code>
trigger myTrigger on ObjectA__c(before insert, before update){
for(Object A obj : Trigger.new){
if(obj.Lookupfield__c !=null){
obj.secondLookUp = obj.LookupField__c;
obj.thirdLookup = obj.lookupfield__c;
obj.fourthlookup = obj.lookupfield__c;
}
}
}
</code>
Regards,
Satish Kumar
All Answers
If not you can write your own apex trigger for this.
<code>
trigger myTrigger on ObjectA__c(before insert, before update){
for(Object A obj : Trigger.new){
if(obj.Lookupfield__c !=null){
obj.secondLookUp = obj.LookupField__c;
obj.thirdLookup = obj.lookupfield__c;
obj.fourthlookup = obj.lookupfield__c;
}
}
}
</code>
Regards,
Satish Kumar
I saw similar solution here: https://developer.salesforce.com/forums/ForumsMain?id=906F00000008zdWIAQ
Will this work?
You can give it a try.
Regards,
Satish Kumar
I have custom Object Propuesta__c with two lookup fields, Opportunity__c and Account__c
I want that Account__c gets populated with the AccountId related in the Opportunity__c
I tried the following:
trigger propuesta_cuenta on Propuesta__c(before insert, before update){
for(Propuesta__c prop : Trigger.new){
if(prop.Opportunity__c !=null){
prop.Account__c = prop.Opportunity__c.AccountId;
}
}
}
but get error: Error: Compile Error: A non foreign key field cannot be referenced in a path expression: Opportunity__c at line 4 column 36
Any help?
thanks