-
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
Best Salesforce Training Program In 2022
If you're seeking the best Salesforce training program to become a Salesforce developer in 2022, you've come to the correct place. Salesforce is a vast…
Forceea: The Enterprise Data Factory We've Been Waiting For | Salesforce
Introduction Everybody needs testing records of SObjects: Developers need testing data for their unit tests. Testers need data for testing. Administrators and architects need data…
Smarter business with the AI-powered data scientist, Einstein Discovery
In this highly competitive market, organizations are constantly trying to analyze their data and make informed decisions to outrun their competitors. That is where data…
Popular Salesforce Videos
Create and Format Derived Measures
In the explorer, you can perform calculations on existing measures and use the results to create a new measure that’s not part of your dataset.…
Generative AI: What Are Its Benefits For Businesses?
Imagine a world where computers can help businesses come up with creative ideas, solve tricky problems, and even predict what customers might want next. That's…
3 Tips on How To Deliver a Successful Product Launch | Salesforce on Salesforce
Salesforce defines a product launch as announcing a new offering to the public. Launches are an opportunity to tell a compelling story about your product,…