Skip to main content
19 votes
Accepted

Set Relationship Via Name Pointing Field?

First, I highly recommend you read Bob's post for yourself. He's a much better writer than I am. Also, Salesforce documents this behavior in Relating Records by Using an External ID and Creating ...
Adrian Larson's user avatar
  • 151k
10 votes
Accepted

updating a records using external Id in Apex

You need to use the external id in the update call upsert flist Externald__c; For part two of your question, seeing that you want to relate the parent and child foo records you can t do it the way ...
Gareth Jordan's user avatar
9 votes
Accepted

System.SecurityException: ViewAllData or ViewAllRecords required to access external id fields which do not have a unique index

The user with whose context the test is running should have View All Data permission on TOrg__c or should have system permission of View all Records if the external Id is not unique. This permission ...
manjit5190's user avatar
  • 8,043
9 votes
Accepted

Should I generate external IDs when not needed to avoid potential query issues later?

TL;DR If you are querying on an indexed custom External Id field, the only way you will give yourself non-selective query errors is by including null in your filter collection. You should avoid that ...
Adrian Larson's user avatar
  • 151k
7 votes

Add a custom field to multiple objects

Assuming all the objects are already created, you could create a file that simply contains the one field definition you need, copy it, and deploy it. I'd say this task is probably easiest with Ant, ...
sfdcfox's user avatar
  • 497k
6 votes
Accepted

Insert Parent and Child Objects of One Type within One DML statement

This approach only works with different types. Take a look at Creating Parent and Child Records in a Single Statement Using Foreign Keys (emphasis mine): You can use external ID fields as foreign ...
Adrian Larson's user avatar
  • 151k
6 votes
Accepted

Salesforce REST upsert for externalId cause DUPLICATE_VALUE error

After a month of discussions with Indian support of all tiers, we've got next: Salesforce can't proceed too fast UPSERT queries. If you send two requests with delay about a second or less you'll get ...
KorbenDallas's user avatar
5 votes
Accepted

How to set auto-number as external Id

When you create a new Auto number field you get an option to make this field an External field. You need to check that checkbox.
Tushar Sharma's user avatar
5 votes
Accepted

INVALID_FIELD, Foreign key external ID not found - Inserting Related Records via External Id

Take a look at Creating Parent and Child Records in a Single Statement Using Foreign Keys (emphasis mine): You can create related records that are up to 10 levels deep. Also, the related records ...
Adrian Larson's user avatar
  • 151k
5 votes
Accepted

Upserting Data using Data Loader with External ID

I will put 2 scenarios over here. I have created following csv file to upload data into my org, where External Site Id is External Id (unique is not selected) External Site key is External Id and ...
Santanu Boral's user avatar
5 votes
Accepted

How to use sfdx force:data:bulk:upsert on an object without an external ID?

Have you tried using Id as external ID field? The documentation uses it in an example: $ sfdx force:data:bulk:upsert -s MyObject__c -f ./path/to/file.csv -i Id -w 2 In addition to that, if you ...
Folkert's user avatar
  • 2,722
5 votes
Accepted

Rest API - Set polymorphic Lookup with external Id

You can specify an External Id, but for polymorphic relationships, you must also specify the correct type of record to use. The following is an example that should work, assuming you are looking up a ...
sfdcfox's user avatar
  • 497k
5 votes
Accepted

Update (never insert) a record by External Id using REST API

A reasonable workaround I found is to use a Composite request: in step 1, retrieve record Id, in step 2, update record by Id using normal PATCH method. POST /services/data/v53.0/composite { "...
mmm321321's user avatar
  • 659
4 votes
Accepted

Add dynamic lookup on Contact to sObject with external Id

You need to make sure that you use the correct relationship name. Here is a simple example that proves this functionality works just fine with a generic SObject record. SObjectField lookup = Contact....
Adrian Larson's user avatar
  • 151k
4 votes

External ID matching no longer an option in Data Import Wizard for custom object to add new records

Make sure that your External ID is set to Unique and you will be able to match by it using the import wizard!
Sebastian Lechner's user avatar
4 votes
Accepted

Upsert Multiple Records with external ID with REST API

You can't do this with the endpoint you're trying to use; the method only allows updating a single record at a time, and uses the following syntax: (PATCH) /services/data/41.0/sobjects/Contact/...
sfdcfox's user avatar
  • 497k
4 votes
Accepted

Is it possible to not use an ExternalId field for Database.Upsert?

The error message is phrased confusingly. It means there's three qualities that must be met for the field to be used: Must be an External Id Must be custom or standard Must be indexed This doesn't ...
David Reed's user avatar
  • 93.2k
4 votes
Accepted

URL link to SF record from external system - LIGHTNING

In lightning you can use "lightning:isUrlAddressable" interface with "force:navigateToURL" to redirect to account page on init with 3 steps. You pass uuid in url You query and find account id on ...
Barış Arslan's user avatar
4 votes

Populate Owner in REST API Using external Id

Even though this question is one year old I had the same issue today and found a solution to that problem. With standard Rest API, your request only needs a slight modification: { "...
ebi's user avatar
  • 236
4 votes

How to use sfdx force:data:bulk:upsert on an object without an external ID?

I know of at least three options for you. sfdx force:data:tree:import should work fine for your situation if you're willing to switch to JSON format for your data storage. The easiest way to do this ...
David Reed's user avatar
  • 93.2k
4 votes

Difference between Upsert and Update database methods

Records sent to update must have the Id field populated (at the very least) to be able to perform the DML. upsert can take a mix of new records (without an Id) and existing records (with an Id). ...
Derek F's user avatar
  • 62.7k
3 votes
Accepted

External Id is not showing up in data loader field mapping

External Id field does not have FLS for System Administrator profile, That's why it was unable to see this field. Background of the issue: Through the change set this field has been migrated to other ...
Santanu Boral's user avatar
3 votes
Accepted

Global Search - Not matches found message

If your intended result to show 10010222964 then you have to search with '*222964' (Please mind the single quote at the beginning and at the end) Though I didn't find this trick in the Wildcards and ...
Santanu Boral's user avatar
3 votes

Should I generate external IDs when not needed to avoid potential query issues later?

You have a few options: Create a formula field that displays text for nulls, then index that formula field For example, assume the Status field is indexed and contains nulls. Issuing a SOQL ...
o-lexi's user avatar
  • 3,094
3 votes

Establishing Parent-Child Relationship via Process Builder

Yes. you can able to do it in a Single Data load provided vast majority of the information fields data you can capture at contact level (May be you can remove the these fields from front end). 1....
user40138's user avatar
  • 948
3 votes
Accepted

Batch Insert child records with External Id

To specify the parent by External ID, you have to create an sObject: public static void createRevenueSchedule(List<Revenue_Pipeline_Schedule__c> scope) { List<Revenue_Schedules__c>...
sfdcfox's user avatar
  • 497k
3 votes
Accepted

Upserting a record using ExternalID is giving an error

You must not put the external ID field/value in the JSON; it is specified by the URL you're hitting. Simply remove that bit from your file and it should work. Here's an example using Accounts: PATCH ...
sfdcfox's user avatar
  • 497k
3 votes
Accepted

Custom Preference Page - External Key (Generate it / Retrieve preferences)

You would create the a cloud page in web studio and link it to the email via the CloudPageURL Function. The beauty of this is it encryts subscibers context data (e.g subscriberkey, emailaddress). You ...
0xsegfault's user avatar
  • 6,603
3 votes
Accepted

Upsert by External Id - Different recordTypes

Is there a way to make an upsert when 2 records or more have the same external Id BUT they have different record type? Unfortunately not. The values within that one field need to be unique for upsert ...
sfdcfox's user avatar
  • 497k
3 votes

External Object Query in trigger

You can create triggers on external change data capture events from OData 4.0 connections Apex Considerations for Salesforce Connect External Objects Use External Change Data Capture to Track Data ...
Oleh Berehovskyi's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible