You need to sign in to do that
Don't have an account?
Deloitte IT Admin 2
Trigger to populate a Lookup when creating a record
Hi All,
I've created a trigger that pupulate the Account lookup field on my custom object.
As shown in figure, when I create a new custom object, my trigger do not write the Account:
But when i press 'Save', the Account field is populated:
I would like to pupulate the Account also in the first picture, when I create a new object.
Here's my code:
I've created a trigger that pupulate the Account lookup field on my custom object.
As shown in figure, when I create a new custom object, my trigger do not write the Account:
But when i press 'Save', the Account field is populated:
I would like to pupulate the Account also in the first picture, when I create a new object.
Here's my code:
trigger afterPlanningTrigger on Pipeline__c (after insert) { for(Pipeline__c p: Trigger.new) { List<Pipeline__c> pi = [select id, Account__c, Opportunity__r.Account.id,Opportunity__r.Owner.id from Pipeline__c where id=:p.id]; pi[0].Account__c = pi[0].Opportunity__r.Account.id; pi[0].Opportunity_Owner__c = pi[0].Opportunity__r.Owner.id; update pi[0]; } }
As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.
Thanks