Questions tagged [upsert]

All queries related to Upsert can be grouped under this Tag

Filter by
Sorted by
Tagged with
13
votes
2answers
7k views

what is the best way to delete a set of records during insert?

I have created a trigger that is supposed to avoid a (lead) record being inserted if it contains an email found in another (contact) record. I am able to get the trigger to update (lead) fields if a ...
11
votes
6answers
18k views

Why does upsert cause a DUPLICATE_VALUE error?

I have a custom object, with a Text Name (ID) field. When I upsert two records with identical Name/ID, but otherwise different values, in two separate upsert statement, one record results, as expected....
10
votes
2answers
13k views

Database.upsert - how to find which records have inserted/updated based on ExternalId

I am upserting list of records based on externalId as follows: List<Database.upsertResult> results = Database.upsert(lstRecords, CustomObject__c.External_Id__c,true); The results returns as ...
10
votes
2answers
1k views

Order of execution for records on DML statements

A list of objects should be inserted in the order it is populated, so lower indexes will be inserted first. This is important when dealing with a List<sObject> where you rely on the order within ...
9
votes
3answers
4k views

Is it possible to Upsert a List<SObject> with external ID specified

I'm getting an error when attempting to compile my Apex: Upsert requires a concrete SObject type In my code, I'm unable to create a concrete declaration for the container which I want to upsert. ...
9
votes
1answer
735 views

Is upsert properly ACID compliant?

Given an object Table_A with one unique field Unique and two rows: row Unique --- ------ 1 A 2 B And the following class: public class KeySwapDML { public void ...
7
votes
2answers
10k views

updating a records using external Id in Apex

I copied the product data to another object named foo. I used only the name and externalId of product to copy it to Foo object. Foo's external id matches with product's external Id. Some of my ...
7
votes
2answers
3k views

Does Upsert alway change the last modified date of the record?

If I run an upsert on a theoretical 100 records, all of which already exist in Salesforce, but only 4 of which have changed field values, will the last modified date for every record be set to the ...
7
votes
3answers
4k views

Upsert Detail object without external Id

I have two related objects (Master-Detail) A -> B (where B is child of A). In addition there is only one B for a parent A. I need to upsert the B object and I only have the A.Id and other fields of ...
6
votes
1answer
3k views

upsert on Custom Setting

I've got a page that inserts/updates a custom setting record. I'm using upsert for this purpose but I've run into an error: There is already an item in this list with the name 005700000037xJaAAI ...
6
votes
2answers
8k views

Adding Contacts to Campaign as Campaign Members

I have a scenario where Contacts are being fed(upsert operation) from a third party application. Along with the Contact information, contact has an External Id for campaign. If a contact is updated, I ...
6
votes
1answer
359 views

Master Encryption Key 1 has already been deleted

I am trying to upsert to Salesforce using PartnerConnection SOAP API. I have no records in my custom object and get the following error when I upsert a new record: Master Encryption Key 1 has ...
4
votes
2answers
343 views

How can I upsert a homogeneous List<SObject>, in a good way? [duplicate]

I have some abstracted code, which at the end of some process will create a homogeneous list of SObjects. It could be a list of Accounts, it could be a list of contacts, it could be a list of some ...
4
votes
2answers
3k views

Can I upsert PricebookEntry Records?

Is it possible to upsert PBE records? According to the API document, upsert is a supported function. Now that we can create custom fields on the PBE, I even added an external ID field, but I cannot ...
4
votes
1answer
1k views

How to use upsert in REST callout JSON

"Upsert" just inserts new records from JSON, but not updates existing. It's my code: public class myClass { @future (callout = true) public static void getCallout(){ Http http = new Http(); ...
4
votes
1answer
1k views

How to find number of records inserted/updated in an Upsert operation?

Is there a way to find how many records have been inserted or updated during an upsert operation? If there is a way, can someone please suggest how to get that details?
4
votes
2answers
2k views

Can we use External Id to update a record using update statement?

I am trying to update a record using an external Id in Apex. The syntax i have tried is given below. update caserecs SAP_Notification_Number__c; But the above statement throws compiler error. If i ...
4
votes
2answers
238 views

where can I find the most recent version release notes of Salesforce Data Loader

I know I can download the Salesforce Data Loader directly from within Salesforce, however, how can I find out what version it is without downloading and installing it? Also, where can I find the ...
4
votes
2answers
2k views

Error executing Salesforce send: Number of results does not match number of SObjects;

I'm getting this error when a Boomi integration attempts to upsert some custom object records into Salesforce. The upsert is using an external ID as the key field (not sure if that helps clarify the ...
4
votes
1answer
858 views

What are Best Practices for Upserting Objects with Foreign Key Members (i.e. References to Other Objects)

I want to upsert objects through the .NET-ForceClient into our Salesforce, more specifically, I want to insert or update an object that contains a reference to another object. As a simple example, ...
4
votes
0answers
172 views

Upserting objects with many to many relationship using api

I am writing a script to run on a schedule to automatically import data from our accounting software into salesforce using their API. I cannot find a good way to upsert objects with many to many ...
4
votes
0answers
2k views

Salesforce Bulk API upsert - Error: ENTITY_IS_DELETED

I am trying to restore a custom object from my backup where I am trying to upsert the records. Following this example. The external field is Id here. Assuming that there are no records matching, the ...
3
votes
2answers
1k views

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

I have a custom object (CustomObject__c) which is a child of another custom object. I want to import some records (CSV files) of CustomObject__c via SFDX (force:data:bulk:upsert). These are the ...
3
votes
2answers
157 views

Does Upsert operation in apex take more time against huge data?

I have a 50 gb data in my org for one object. My triggers will fire and upsert a record on it, does the volume of data show any impact in performing the UPSERT DML operation.
3
votes
1answer
2k views

Upserting Data using Data Loader with External ID

I'm using Data Loader in order to Upsert some data within my Org. I know, that if I will Upsert a record within my CSV that has duplicate External Id value with another record in the file, It will ...
3
votes
2answers
2k views

DML not allowed on User

I created some test users using the following apex code which worked perfectly fine: list<User> abc = new list<user>(); for(integer i=1; i<3;i++) { abc.add( new User( ...
3
votes
1answer
836 views

Does Upsert work with Custom Settings?

I am trying to create and update records in Custom Settings object. I am able to use insert but did not find an option to upsert. Does upsert work with custom settings? Please suggest.
3
votes
2answers
66 views

Can the exact type of an Apex list be checked to choose between upsert and insert/update?

I have a utility method that that works on lists of SObjects that are normally of one type: private void oneType() { Contact[] contacts = new Contact[] {}; contacts.add(new Contact(...)); ...
3
votes
1answer
903 views

Multiple upsert: Creating Parent and Child Records in a Single Statement Using Foreign Keys

The following is my Apex class to upsert the below input into salesforce. INPUT {"req" : { "tickets": [ {"External_TicketID__c" :"66", "Date_Time__c": "2015-09-13T22:30:00.000Z", ...
3
votes
1answer
251 views

How to Interpret Bulk API UpsertResult element?

Below is the Result of the Bulk API job(batch) I submitted : <?xml version="1.0" encoding="UTF-8"?> <results xmlns="http://www.force.com/2009/06/asyncapi/dataload"> <result> ...
3
votes
2answers
2k views

Upsert query with only one record to insert/update

Is it possible to upsert only a single object? And return the ID of the inserted/updated record? I have an Custom Contact Object which i want to insert into the standard Object from Salesforce. The ...
3
votes
1answer
3k views

Salesforce Apex Data Loader GUI vs. Command Line login

(Crossposted from SO - https://stackoverflow.com/questions/21255608/salesforce-apex-data-loader-gui-vs-command-line-login) I'm trying to wrap up some Upsert functionality into a simple application ...
3
votes
2answers
403 views

PHP Toolkit 20.0 (Enterprise) Upsert/Update Custom Object - deserializer not found

I'm using PHP Toolkit 20.0 (Enterprise) and the latest WSDL. Partner also fails for me. I can successfully create (using PHP Toolkit create) objects of this type. All my attempts to Update or Upsert ...
3
votes
2answers
2k views

INVALID_ID_FIELD when upserting an attachment through Bulk API

The situation is as follows: In my Salesforce org, I have a contact, let's call it Humpty Dumpty, and I'd like to attach a file to it, let's call it cooking.txt, but there are some rules: If there ...
3
votes
1answer
307 views

Upsert externalIDField

I am trying to run an upsert from a batch script. I can't seem to track down any documentation on the actual mapping file when using an external id from a .csv file. How do I tell my upsert which ...
3
votes
1answer
803 views

Jitterbit time format issue

I am using Jitter bit to load the data into SFDC. I have the separate fields for date(Field1) and time(Field2) in my text file. I have the upsert query and I did the mapping for salesforce like this, ...
3
votes
0answers
239 views

How to insert records into an SObject using python beatbox module?

I am looking through beatbox's github repo here https://github.com/superfell/Beatbox/blob/master/beatbox/_beatbox.py#L122 And I am not sure whether I am using it correctly, specifically I am not sure ...
3
votes
1answer
899 views

programmatically selecting picklist item dependent value

I am writing a program which reads data from CSV text files and attempts to upload data into my organization's Salesforce account. I am writing this console application in C# and with my organization'...
3
votes
0answers
284 views

request.patch gives duplicate value found error for a Salesforce API

I have referred this guide to make patch request to a salesforce api. My python code : headers = {"Authorization" : "OAuth %s"%str(accessToken), "Content-Type" : "application/json"} try: ...
3
votes
1answer
965 views

INVALID_CROSS_REFERENCE_KEY, invalid cross reference id

I am trying to upsert the list below: OpportunityLineItem:{ Id=00k11000007NorcAAC, ServiceDate=2014-03-30 00:00:00, UnitPrice=200, Quantity=1, ProposalID__c=1, Status__c=IN_APPROVAL, ...
2
votes
3answers
661 views

Upsert failed in apex

I'm trying to do upsert and I get duplicate error on Unique field. Shouldn't upsert take care of whether to update an existing record or to add a new record? Error: caused by: System.DmlException: ...
2
votes
1answer
4k views

Error: Accounts: Cannot specify any additional fields when marrying or separating a Person-Account

I'm using an ETL tool Talend for data push to salesforce. When I'm upserting the accounts getting the error below In the mapping I specified the business accounts recordtypeId but still is throwing ...
2
votes
1answer
1k views

Help with trigger defaulting multi-select picklist fields

I'm fairly new to coding and my admin has asked me to create a couple of triggers to update a multi-select picklist for our Opportunity page or maybe I could combine them into one. I have created the ...
2
votes
1answer
275 views

How to use simple salesforce (python library for salesforce) to add ShippingAddress field?

I have tried to upsert an account with ShippingAddress using simple salesforce However, I am getting the error: [{u'errorCode': u'JSON_PARSER_ERROR', u'message': u'Cannot deserialize instance of ...
2
votes
2answers
56 views

How to update existing records and upsert new records

I want to update existing task records but a new record gets created instead . What am I doing wrong. Apex: public static void Activities(List<Account> accounts) { Set<Id> persAccIds = ...
2
votes
3answers
6k views

Bypass validation rules / duplicate rules during Import via DataLoader

I'm trying to import some data into a standard object like Account via the DataLoader. The problem is that, I have a duplicate rule on a specific field, and I set this field as required. When I want ...
2
votes
1answer
743 views

Get the inserted record id in a upsert call?

I am using below code to get the id of all record id whether it is update of inserted. upsert custmerList Name; for(customer__c afterUpsert : custmerList){ system.debug('*** Id = ' + afterUpsert....
2
votes
1answer
410 views

Is upsert the right thing to save new or existing records?

In many of my Controller extensions I have save action methods that work for NEW and EDIT scenarios. I simply use upsert record instead of update / insert record in such cases. But now I am running ...
2
votes
1answer
640 views

Upserting objects in Apex: can I assert which have been inserted / updated?

I'm upserting a list of custom objects in an Apex controller that are retrieved on demand from an external source. My object has an external identifier field used to help the database call determine ...
2
votes
1answer
490 views

What Is The Limit On Record Count When Using Upsert in Apex?

When using Apex in a transaction, what is the maximum number of records that can undergo the upsert command? Example: I am consuming a web service (SOAP) that returns me a lot of information. I ...