I m new to salesforce.i have custom object Lease__c , i wanna update the account name and owner field from opportunity.In lease__c i have lookup for opportunity field.how to write trigger for Lease__c for after insert
On custom object Lease__c
, create two new formula fields. These are called cross-object formula fields.
Account_Name__c with formula expression = opportunity__r.account.name
Opportunity_Owner__c with formula expression = opportunity__r.owner.name
If the Lease's opportunity owner changes, any reports or views on that Lease object will automatically pick up the new owner name; same if the Lease's Opportunity's Account name changes (or even if the Opportunity is switched to a different Account).