-
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 Awesome Admin Tips for Productivity | Salesforce Admin
It’s no secret that Salesforce continually ranks as one of the highest recommended cloud-based software management platforms. It has proven to be an incredibly robust…

What is Batch Apex in Salesforce? How to Execute Batch Apex Class?
Batch Apex In Salesforce If you want to process a large number of records every day or within a certain time interval, you may encounter…

Cache Lightning Platform Data - Salesforce Developer Guide
Using the Platform Cache can enable Salesforce applications to run faster because they will store reusable data in memory. Salesforce applications can easily and quickly…
Popular Salesforce Videos
How to Send a Pardot Email with Multiple Line Items | Salesforce
It is impossible to send a Pardot email that has a list of related records… or is it? In this session, Adam Erstelle uncovers strategies…
Permissions In Salesforce Experience Cloud Explained | Salesforce Communities
A permission set is a collection of settings and permissions that give users access to various tools and functions. Permission sets extend users' functional access…
Salesforce JMS Integration Using MuleSoft | Salesforce Tutorial
Salesforce JMS Integration. In this video, the following points will be covered - 1. Introduction Learn how to use queues to integrate data in Salesforce.…