-
How can I add a lookup relationship using an external id on a before insert/update trigger in Salesforce?
I would like to create a lookup relationship to a parent object using the parents external id from a before insert/update trigger. I am not receiving an error when I do this, but it is not creating the relationship. I have tested using anonymous apex with a dml and the code works fine. In the example, Tech1_ID__c is the external id of the Property__c object.
trigger CaseAddressHandler on Case (before insert, before update) {
for(Case c: trigger.new){
c.Property__r = new Property__c(Tech1_ID__c =c.Property_Id__c);
}
}
Log In to reply.
Popular Salesforce Blogs
![Salesforce Product - Sales Cloud](https://images.forcetalks.com/wp-content/uploads/2018/01/25083017/Salesforce-Product-Sales-Cloud.png)
Salesforce Product : Sales Cloud
Salesforce: Sales Cloud Overview Sales Cloud is a part of CRM and a product of Salesforce which is mainly created for salespeople because it's such…
![Salesforce Communities](https://images.forcetalks.com/wp-content/uploads/2022/02/09175348/Salesforce-Communities.jpg)
Introduction to Salesforce Communities: Licenses and Benefits
What are Salesforce Communities? Salesforce is a San Francisco based organization that gives client connection to the board (CRM) programming arrangements. Most importantly, Salesforce people…
![](https://images.forcetalks.com/wp-content/uploads/2022/03/30060501/sa_1648620008No%20Code%20Clearbit%20and%20Salesforce%20Integration-1024x576.png)
No Code Clearbit and Salesforce Integration
Clearbit is a consumer contact marketing data engine. It assists businesses in expanding by delivering solutions that enable them to better understand their clients, discover…
Popular Salesforce Videos
Future Methods | Asynchronous Apex | Salesforce Tutorial
Asynchronous Apex 1. Future Methods 2. Making callout using future method 3.Avoiding Mixed Dml using Future Method 4. Why sObjects and objects cannot pass as…
Copy to Clipboard Functionality in Salesforce - Lightning Component Projects Series Part 2
In this video, I'm creating a lightning component Project for functionality i.e Copy to Clipboard. Watch this video and learn. If you have any doubts…
Introduction to Asynchronous Apex In Salesforce
Here is the first video on Asynchronous Apex where you get a bit idea of why to use and why there is a need for…