Questions tagged [dml]

Use this tag for questions about DML, the data manipulation language used in apex to perform operations as insert, update, delete, and restore data in the database.

Filter by
Sorted by
Tagged with
0 votes
0 answers
49 views

CPU Time Limit Exceeded Trying to Email 2000 Contacts

I have a junction object called AccountContactRelation which is linked to both the Contact and Account objects. I am trying to sort through the accounts, and for each one, add all the related ...
user avatar
1 vote
2 answers
132 views

CPU Timeout Error When Inserting 2000 Records through Apex

I created an apex class that is activated by a button for a 1 time use insert of about 2000 enrollment records. The code works with small amounts of records but when with the full 2000 I get a ...
user avatar
0 votes
1 answer
21 views

Get record field after Error in Database.Upsert

I'm upserting some records using Database.upsert, after that, I'm supposed to get the errors and pass them to a custom logger. The problem is, the way this class works, I'd need to get a field value ...
user avatar
0 votes
0 answers
23 views

Enforce CRUD on single record DML statement

As the title suggests I am trying to enforce CRUD on a DML statement for a single record. I see the stripInaccessible() method takes in a list of sObjects. Is there an equivalent method for a single ...
user avatar
  • 177
6 votes
1 answer
96 views

Performing DML on empty list in a flow consumes governor limits but doing same in apex does not?

I tried to make a dml call on an empty list in an autolaunched flow and after looking into the debugs, I got to know that governor limits are getting consumed. But the same is not true when we perform ...
user avatar
  • 109
0 votes
1 answer
60 views

Apex: Avoid DML when records are unchanged

I have noticed that many of the Apex triggers in my org update records even when there are no substantive changes to those records. For instance, consider a trigger that sets field values on an object ...
user avatar
1 vote
1 answer
197 views

Spring 22: DML operation Delete not allowed on List<CUSTOM OBJECT> [duplicate]

Similar situation to wanwan at: DML operation Delete not allowed on List<CUSTOM OBJECT> But I dont have reputation to be able to comment :-( Customers of our app started getting issues as soon ...
user avatar
1 vote
1 answer
214 views

DML operation Delete not allowed on List<CUSTOM OBJECT>

I have a scheduled job named "Scheduled_Mail" and its class is "Scheduled_Mail_Controller". From February 13, suddenly the following error occurs. 'Scheduled_Mail' : Dependent ...
user avatar
  • 13
0 votes
2 answers
64 views

Database class partial success can exceed governor limits?

I have a question about the partial success using database class. My question is, if i exceed governor limits. Will the whole transaction be rolleback or i'll have in the database the records that ...
user avatar
0 votes
1 answer
93 views

How to get the parent id in a master-detail relationship and assign it to the child id

I am new to apex and I have created an apex trigger that will create new residents whenever a city census(custom object) is approved. The created residents is based on the contacts object's details ...
user avatar
0 votes
1 answer
42 views

Too many DML statements: 1

im working with LWC, creating a button to upload files. but, when i click submit button console shows that error: "Too many DML statements: 1" <template> <lightning-card title=&...
user avatar
0 votes
1 answer
35 views

Not able to insert parent and child record using database.Insert in one go

In my case eSales_Order__c is the Parent object and having Master detail relation ship to eSales_Order_Line__c. So I am trying to insert into both Parent and child at same time . I am having a common ...
user avatar
  • 59
-1 votes
1 answer
54 views

Is there an hourly API/DML limit? Or per-user limit?

I know there's the daily/monthly limits, which we aren't exceeding. However, we are seeing an issue where one of our Integration Users is seeing their API calls stalling out, but at the top of the ...
user avatar
  • 77
1 vote
2 answers
27 views

How to avoid Multiple DMLs on a single transaction while populating Rollup fields in Lookup relationship using triggers

I have a trigger on child object.From the handler I am calling the helper method multiple times to update 4 rollup fields on parent record. I have a working logic but I am concerned about repeatedly ...
user avatar
0 votes
1 answer
71 views

FLS Create Security Risk still appears even though object is checked if it is creatable

So I have this code: obj.field1__c = 'placeholder'; if(MyCustomObject__c.sObjectType.getDescribe().isCreateable()){ insert obj; } When I receive the (Checkmarx Source Scanner report), I still get ...
user avatar
0 votes
1 answer
65 views

Skip Sobject that has an error during DML operation

I have a list of Sobject which I'm trying to update, but I want to skip those Sobjects that throw an error or more precisely those that have Sobject.addError('') during the trigger call. i.e if I ...
user avatar
0 votes
1 answer
67 views

Upsert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION Invalid vote type '5-star(db=6,api=5)'

//This method is used to upsert an vote for article @AuraEnabled public static String upsertVote(Id voteId, String kbId, String val){ System.debug('voteId::'+voteId); System.debug('kbId::'+...
user avatar
  • 35
0 votes
1 answer
238 views

Error: Opportunity must have a primary quote in order to create an order.: [] - SBQQ CPQ Test class

I am very new to CPQ, and I am given a test class to write directly. When I try creating order in my test class, I am getting this error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Opportunity must have a ...
user avatar
2 votes
1 answer
53 views

Lookup fields have id values even though parent object has been deleted - tips on fixing?

In a sandbox org whenever I try to perform any DML on a Product2 object I'm getting the generic invalid cross reference key error even if I'm only supplying the id field. 16:59:05.12 (140169065)|...
user avatar
0 votes
1 answer
31 views

Update parent field

I have an order which I am creating from another order and I have lookup on order - ParentOrder__c. When I create the child order, I would like to update field Prolongated__c(which is checkbox) on ...
user avatar
0 votes
1 answer
96 views

Difference between Upsert and Update database methods

Good morning. Database.update (fields , allOrNothing) Database.upsert (fields, externalId, allOrNothing) I need help to understand why the second parameter "externalId" is not necessary on ...
user avatar
  • 27
3 votes
1 answer
112 views

Security.stripInaccessible not returning Id of new records (running as sys admin)

I am trying to update my existing code to use the fancy new Security.stripInaccessible method. My current code to create records is very generic and so I have a method header something like the ...
user avatar
0 votes
0 answers
52 views

"You have uncommited work pending" when there's no obvious DML?

I have a RestResource which is running some callouts, as well as running some DML (after the callouts). I'm recieving this error: You have uncommited work pending. Please commit or rollback before ...
user avatar
  • 155
0 votes
1 answer
38 views

Upserting a list of SObjects is creating duplicates

I have an external Id field called Unique_Identifier__c which is a concatenation of two fields on this Custom SObject Recipient. This field is created/populated at before insert. I want to allow the ...
user avatar
-3 votes
1 answer
212 views

inserting records using Apex Web service [closed]

The user has access to apex class.I am trying to insert accounts using apex web service. and making a callout using apex. This is my code.but it seems that the apex web service is not receiving the ...
user avatar
0 votes
1 answer
70 views

Can we delete list which contains different SObjects with one DML statement?

I have List which can contains Accounts and Contacts ; Can we delete the list using just ? List<SObject> testList; delete testList; Can we delete list which contains different SObjects with ...
user avatar
2 votes
1 answer
229 views

Why am I getting a "Too many DML statements: 1" in a non-cacheable Apex method?

I have this Apex method in a controller class: @AuraEnabled public static void deleteTagAssignment(Id loanId, String name) { TagAssignment__c assignment = [ SELECT Id FROM ...
user avatar
  • 653
0 votes
1 answer
62 views

Navigation Link Set: Too many retries of batch save in the presence of Apex triggers with failures: when triggers are present partial save requires

I am trying and deploy a Navigation Link Set But, I am getting error message: Too many retries of batch save in the presence of Apex triggers with failures: when triggers are present partial save ...
user avatar
  • 8,213
2 votes
1 answer
435 views

Flow component : Delete Records

I have a Screen Flow. There is one Screen Element containing a Lightning Web Component which is based on the standard lightning-datatable component, which allows the user to edit a set of records. ...
user avatar
  • 611
-2 votes
1 answer
17 views

Update sibling records from the same object fails

I have a custom object called 'myObject__c'. This object has a lookup with Account. Now I want to get the values of an existing record (e.g. recordA) and update another record (e.g. recordB). this is ...
user avatar
  • 21
-3 votes
1 answer
101 views

DML and callout in same future [closed]

I need to do a call-out to get a token on the trigger. In this case, you need to save this token through the DML operation. Callout and trigger cannot be performed in one operation. How can I make a ...
user avatar
-3 votes
1 answer
33 views

Integration of salesforce for file uploads and insert [closed]

Is there any way to upload, insert files from any excel sheets(google sheets, MS,...) into salesforce records?
user avatar
0 votes
0 answers
37 views

Apex for Admin Trailhead: Code Not Working

I'm working through the Trailhead and have triple checked my work, watched the video that goes along with the unit, and have researched the problem as much as I know how. The problem is linked here:...
user avatar
0 votes
1 answer
99 views

Update record in rest callout

Hi I try to update an existing record using REST callout. String uri = 'https://test--dev.my.salesforce.com/services/data/v25.0/sobjects/Account/' + ACCId; HttpRequest reqUpd = new HttpRequest(); ...
user avatar
0 votes
2 answers
51 views

Hi, I would like to know if anyone can help me to write a method to have better this code and if this have errors can you tell me that error

public class MyPageController { public void recalculateTotals() { List<MyCustomObject__c> myCustomObjects = [SELECT Id, Totals__c, Recalculate__c, Value1__c FROM MyCustomObject__c]; ...
user avatar
1 vote
1 answer
270 views

How to compare the Database.Error getStatusCode() value against a string (In a clean way)

I have the following code which uses string concatenation to check the err.getStatusCode() if (err.getStatusCode()+'' != 'ENTITY_IS_DELETED'). My question is, if there's a cleaner/better way to do ...
user avatar
  • 564
0 votes
1 answer
248 views

Logging Apex exceptions through Event Bus while still rolling back the entire transaction?

I'm working on implementing a robust error logging framework for our org using Platform Events to ensure that we always capture errors in our code even if the transaction is rolled back. If I use ...
user avatar
-2 votes
2 answers
1k views

Apex error : You have uncommitted work pending. Please commit or rollback before calling out [duplicate]

Apex error : You have uncommitted work pending. Please commit or rollback before calling out. I get the above error when I try to make two http callout one after the other and store the result in ...
user avatar
  • 11
0 votes
0 answers
152 views

insufficient access on cross reference Id during insert of child detail record in after insert of parent record

public static void createQuoteLineItem(sales_Toolkit__c[] newQuote, OpportunityLineItem[] oppLine { List<Conversion__c> newQline = new list<Conversion__c>(); Id parentQuoteId; //...
user avatar
  • 465
0 votes
0 answers
271 views

Duplicate Record Being Created on Update DML

I seem to have tracked down where duplicate records are being created, and I believe it is in this updateRecordGuest class. This class is wired in a LWC and we are passing in the record Id for the ...
user avatar
1 vote
1 answer
109 views

DmlException Creating CMS Library/Folders

I have some Apex code written to create a new Account, and then create a new Library (ContentWorkspace) and new Folder (ContentFolder) within that Library to house assets for that Account. It appears ...
user avatar
0 votes
1 answer
775 views

System.TypeException: DML operation INSERT not allowed on QueueSobject

I am trying to insert a QueueSObject in test class but getting the error System.TypeException: DML operation INSERT not allowed on QueueSobject This code was working before but started giving error ...
user avatar
1 vote
0 answers
102 views

RowCase is manual but still can't delete account share

This code here fails: List<AccountShare> existingShares = [SELECT Id FROM AccountShare WHERE RowCause = 'Manual' ...
user avatar
  • 465
0 votes
1 answer
38 views

Security with Mixed SObjects

I am attempting to find best practices around mixed SObject security. When I am using DML statements I validate either through "with SECURITY_ENFORCED" or through {SObject}.SObjectType....
user avatar
3 votes
1 answer
265 views

Updating an instance of Custom Setting via DML

So I implemented a callout to an external service where first we should validate that our token wasn't expired. So I implemented a refresh token method, that updated our custom setting where we stored ...
user avatar
1 vote
0 answers
175 views

Updating Opportunity Splits in Apex field integrity exception

I'm trying to automate Opportunity Splits and I'm running into the following when trying to upsert them for a given split type: System.DmlException: Upsert failed. First exception on row 0 with id ...
user avatar
  • 1,007
0 votes
0 answers
64 views

Way to partially filter inserted records in before trigger

Let's say we have bulk DML that is gonna insert a couple of records. In before trigger we want to check all new records and insert only correct (matched) ones. Should we use another DML inside the ...
user avatar
  • 687
0 votes
1 answer
51 views

Block an insert call or convert it to upsert in trigger

Zapier connects our forms to our Salesforce instance. However, Zapier does not provide an upsert call as a way to insert a record, only insert and update. This means we have to use up more of our ...
user avatar
0 votes
1 answer
563 views

To check if there is any opportunity present in account. If yes do nothing, else we have to create at least one opportunity under that account

trigger atleastoneopp on Account (before update) { List<Opportunity> oppList = new List<Opportunity>(); Map<id, Account> m = new Map<id, Account>(); // Select query before for ...
user avatar
-1 votes
1 answer
31 views

I am updating a child record in a parent record's before update, which directly changes a rollup summary field on parent record of that child record

This causes a SELF_REFERENCE_FROM_TRIGGER error. Is there a workaround for this type of scenario? I have outlined the trigger and object situation below: Object Info: Parent | Fields: RollupStage__c, ...
user avatar
  • 105

1
2 3 4 5
10