Questions tagged [database.insert]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
21 views

Get all the Ids that were inserted by Database.insert - without iterating each record

We are using the Database.Insert(leads, false); We want only the the ids that where insert. We have a lot of leads to be checked if we use for (Database.SaveResult result: results) { if (result....
2
votes
1answer
46 views

Unexpected behaivor: Database.insert(userList, false) is rolling back User insertion

I am attempting to insert two users with the database.insert method. One user that should work, and another that is missing required fields. // Create two users, one of which is missing a required ...
0
votes
0answers
46 views

Error saving data to an external object

When trying to save data in an external object the following error occurs: FATAL_ERROR|System.UnexpectedException: A callout was unsuccessful because of pending uncommitted work related to a process, ...
0
votes
1answer
95 views

How to use insertAsync with processSave

I am trying to understand how insertAsync(sobjects, callback) works with processSave(saveResult) I went through the following two documentations, but couldn't find an example anywhere https://...
2
votes
1answer
94 views

Salesforce Relational Database ACID

I was reading about relational databases and found that Salesforce is built on Oracle's Relational Database. Based on my understanding, Relational Databases "promise" the following ACID principle: ...
2
votes
1answer
42 views

Not able to insert data successfully

I am trying to create a lightning component through which I would be able to insert both Account and Contact data together. But I am not able to do so. Can anyone kindly let me know why this is ...
2
votes
1answer
47 views

How to determine when retry attempt is happening with allOrNothing

We have code using the Database.insert/update(records, false) syntax. I know how to handle the errors after the fact, so that is not the issue, but when using static recursion flags, the first attempt ...
0
votes
1answer
84 views

Database.update is not working as expected

I am trying to write a code which will query account records and lock them using FOR UPDATE keyword and then I am also triggering another batch which will try tu update same record with some more ...
-1
votes
1answer
158 views

Database.Upsert not able to prevent AllOrNone

Elaborating the Question:- We have 3 Objects, Branch, Account and Branch Accounts, Branch Accounts is a junction between former 2. Now we are trying to insert Branch Account records via Batch, and in ...
0
votes
1answer
32 views

AuraEnabled returning success records instead of failed records

I have apex AuraEnabled function which is inserting records for a junction object, however due to some validation rules, some of the records may get failed. So I have a solution to maintain a list of ...
0
votes
0answers
67 views

Test Class - SOQL in Test Returns No Results using Database.Insert(RecordList,DML), but works using Database.Insert(RecordList)?

I am creating test coverage for a new Lead Process we've built for our company. To properly test this deployment, I need a list of Leads to show as being Inserted by our Pardot API connector user, and ...
2
votes
1answer
78 views

How to throw or cause an Access Level exception in a test class

anyone know how to throw an access level exception in a test class to cover the below code sample? I'm assuming the object being inserted with Database.insert needs to have sharing settings modified ...
1
vote
1answer
384 views

Database.insert(list, false) run trigger twice? [duplicate]

Example: If we are inserting 10 records in an object, Where 5 records are correct and the remaining 5 records are incorrect. • In Database.insert 5 records will be inserted, remaining 5 records ...
0
votes
0answers
177 views

@future method not getting called from catch block

I am calling a webservice (synchronous) and in case of CalloutException, I'm trying to create an error log in a custom object. The problem is, the record insertion is happening in a future method and ...
1
vote
1answer
26 views

Record Insertion using Lightning,

I need to insert a record to a custom object throught the lightning page that I have created. but i am getting the attached SS error. Could any1 tell me what I am doing wrong ? CMP:- <aura:...
1
vote
2answers
592 views

Does Database.SaveResult, Database.DeleteResult, etc. implement a public interface?

The various DML operations (insert, update, delete, etc.) all return results with very similar methods and properties. It is not uncommon, as a developer, that I should want to handle these results ...
0
votes
1answer
2k views

How to avoid: Error uncommitted work pending in my testclass

I am doing do a callout trough a processbuilder with a future call. Before I do the call I get some variables from a custom setting. When I do an insert in my testclass for my custom setting I get the ...
0
votes
1answer
627 views

How to get the Id of Inserted records from Database.Upsert? [duplicate]

I'm having this dilemma regarding the result for Database.Upsert(List, boolean). Database.Upsert returns Database.UpsertResult and it provides as the Id of the record that was successfully inserted/...
1
vote
3answers
1k views

Sending Email to Queue Members On Lead Creation Without Using Assignment Rules

I have 2 Users that belong to the queue 'Sales' with the Send Email to Members checked. I have an online app that creates a new lead, and sets various lead fields, but the email is not sent to ...
0
votes
1answer
87 views

Duplicate ID in list causes whole UPDATE to fail although allOrNone is set to false

A duplicate ID in my list of SObjects "businessPartnerListToUpdate" Database.SaveResult[] saveResultList = Database.update(businessPartnerListToUpdate, false); causes an Exception to be thrown: ...
0
votes
2answers
105 views

Rolling back a complete transaction

I have two object foo__c and zoo__c. zoo__c is a child of foo__c with a master detail relationship. I have validation rule created on Zoo__c with a condition that when the status__c field on related ...
1
vote
2answers
98 views

pageMessages should ignore Database.insert(records, false) errors

I am creating some records in my controller but some of them might fail during insert due to duplication, so I use Database.insert(records, false). It works just fine and ignores records that already ...
2
votes
1answer
58 views

How to create cascading objects while offline with SmartStorage and the mobile SDK

Do you have any ideas how to create cascading objects (e.g. create a new Soup A entry that contains an also new Soup B relationship entry) while in offline modus and using the SmartStorage of the ...
1
vote
2answers
152 views

Prevent insert if object in list is not valid and find which record is invalid

I am developing lightning component, on which user enters data in table and creates multiple records. If some records do not pass validation - row has to be highlighted with red. For this I need to ...
0
votes
1answer
1k views

Get field values of newly created record other than Id

Is it technical feasible to obtain fields like OwnerId, Name from newly inserted record from database.Saveresult? Apex code: for(Database.SaveResult sr: srList){ if (sr.isSuccess()) { Id ...
0
votes
1answer
43 views

saving skipped record detail

I am creating List of Accounts, using database.inser(list,false) if i did give name for record in list,it will skip that particular and insert remaining records, is there any chance to get the details ...
1
vote
3answers
18k views

Database.insert(list,false) in apex

I am creating List of Accounts, using database.inser(list,false) if i did give name for record in list,it will skip that particular and insert remaining records, is there any chance to get the details ...