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.

73 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6
votes
0answers
173 views

How many child records can a parent cascade delete (documented limit)?

I have a CustomObject__c which has childrens 2 level deep. Together a single parent object can have many 10.000 child records. Would it work to auto-delete the thousands ob child records just using a ...
5
votes
0answers
339 views

No DML_END Issue

Yet another "what gives" question. I have a custom object that is updated upon a button click on a VisualForce Page. I can see in my debug logs that the object has been updated. But when I refresh ...
5
votes
1answer
1k views

How to save large files in Salesforce with synchronous Apex?

I've created a Visualforce page that allows users to drag and drop files and have them uploaded to Salesforce and then displayed in a list immediately. To do so, my VF page sends the file in chunks ...
5
votes
1answer
376 views

Does opt_allOrNone guard against partial lead conversions?

There is a brief note at http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_convertLead.htm about opt_allOrNone preventing partial success of the convertLead DML operation: The ...
4
votes
0answers
51 views

Should I be concerned about thousands of write operations per minute?

I am setting up a POC which would create a junction between User and Case (using Lookup relationships only). We would have 10k+ users each touching several records per hour, so we might expect this ...
4
votes
0answers
712 views

INSUFFICIENT_ACCESS_OR_READONLY - Cannot Delete QuoteLineItem

17 QuoteLineItem records were loaded into the org via Dataloader with the incorrect product2id listed. When trying to delete the records in the GUI while logged in as a System Administrator, the ...
4
votes
0answers
145 views

DML takes long time on custom object with no triggers/WF/PB on it

I've got a code, where on lead insert, I also insert 1 record of custom object Demand_Funnel__c. Demand_Funnel__c has no apex triggers, no WF rules, no Processes tied on it. If it's a first lead ...
4
votes
0answers
97 views

mixed_dml on batch execution on unknown standard object

I'm running a batch that updates several custom objects. Sometimes I get a mixed_dml error but it's not something I can reproduce, It's an intermittent error. The message that is thrown is: ...
2
votes
0answers
81 views

Apex sharing insert

We are now investigating some performance issues for the client and trying to speed up their processes. One of the time consuming parts is apex sharing that we have there. I am pretty sure that some ...
2
votes
1answer
78 views

Query related to DML Example for AccountWrapper

I am trying to implement below example shown in screenshot :- I want to check that for records where checkbox is selected, name field should not be null, then only insertion should happen, but name ...
2
votes
0answers
989 views

Add Error on standard list view

does someone know how to show an error in an object's listview after a dml operation? I have written a simple trigger that prevents user to delete closed opportunity List<Opportunity> ...
2
votes
0answers
108 views

How to update the current login user

I have a custom field over my user object. And I want to update this user by the contact id from apex. How can i update the user record in salesforce. Because when I trying to update the field of ...
1
vote
1answer
68 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 ...
1
vote
0answers
65 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' ...
1
vote
0answers
84 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 ...
1
vote
0answers
82 views

Managed Package Platform Event and DML by unlicensed user

I am working on a managed package which will be licensed per user. The package will include two features: Feature A: Global Apex Class that publishes platform events (also packaged). Trigger on this ...
1
vote
0answers
160 views

Process Builder - Record Update & Number of DML

In a process builder, if you have a node with multiple "immediate actions" for updating records, do those all get processed as one dml on that record in question or do they each count as distinct ...
1
vote
1answer
1k views

Possible Workaround to perform DML when cacheable is true

According to documentation, it is recommended to make wired apex calls from LWC cached, by adding the following annotation to the controller's method: @AuraEnabled(cacheable=true) However, adding ...
1
vote
2answers
103 views

Cover Error Handling on Test Class

I am having an issue where I have a trigger that rolls up data from contacts to an account. This was working fine with no issues until we added a managed package app that is constantly checking and ...
1
vote
0answers
53 views

Updating event restores event relations I just deleted?

I have need to programmatically delete an event relation for an event, then add a new one, then do some updating of the event information, then update the event. I have ran into some roadblocks: If ...
1
vote
0answers
25 views

Enforce DML statement to be failed within a batch

I am trying to make a DML statement in a batch to be failed. The reason for this is that I have logic executed in my batch in case the DML failed for some records. I would like to test it and get the ...
1
vote
0answers
195 views

Large time gap in debug log before ENTERING_MANAGED_PKG

When viewing a debug log where the logging level was set to: APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO I am seeing a large ...
1
vote
0answers
337 views

Mass/Bulk Update Campaign Member Status Over 200

I am looking to update all of the related Campaign Members' Statuses from a Campaign based on the execution of a JavaScript button and an APEX Class. The button below works to update the status from '...
1
vote
1answer
24 views

Cases added with Prefix as "RE".How to display them in a while Statement

We do get case added with the Prefix as " RE " or "FW "So we give them in a while stmt ,as : while(c.Subject.startsWith('RE:') || c.Subject.startsWith('FW:')) Similarly case added with the Prefix ...
0
votes
0answers
46 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 ...
0
votes
1answer
32 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 ...
0
votes
0answers
35 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:...
0
votes
0answers
38 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; //...
0
votes
0answers
168 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 ...
0
votes
0answers
107 views

Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, unexpected metadata: []

I'm creating a time based flow in which I have to delete Opportunity Team Member Record after 2 hours of createdDate when it's custom checkBox field is 'true'. But when I'm inserting an Opportunity ...
0
votes
0answers
43 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 ...
0
votes
0answers
128 views

Storing large string in Salesforce

I am currently handling an oAuth 2.0 PKCE authentication flow (not supported by Named Credentials). At the end I get an access_token that is around ~1200 chars, this token lasts for about 30 minutes ...
0
votes
2answers
215 views

i am getting this error System.FinalException: Cannot modify a collection while it is being iterated

//write trigger on contact when we edit contact. the contact name comes along with account name trigger ContactNameWIthAccountName on Contact (before update) { List<Contact> listOfContact = ...
0
votes
0answers
33 views

Api Integration Issue

I have created an api integration in salesforce. From client's website a request will send to Salesforce in form of JSON. This will create record in Salesforce. Sometimes multiple requests are sent ...
0
votes
0answers
58 views

Auth.RegistrationHandler fails when creating Account

lately i am facing wierd issue. I've created SSO for my community and till some point it worked fine. Lately I've found out it is failing when creating Person Account and I have no idea why. Code is ...
0
votes
0answers
21 views

Scope of SavePoint variable

I am trying to upsert parent records in a class as well as it calls another class which inserts child records. I am trying to add Savepoint to rollback the transaction and prevent parent record from ...
0
votes
1answer
56 views

Insert JSON to salesforce

I have a JSON which I got from An outer System to Salesforce and I should eventually insert it to SF. { "AFTR0": [ { "AFTR1":"U", "AFTR2": "3dcda8f9213ad43aafe456ae489a158b", "...
0
votes
2answers
373 views

Visual Flow and Callout

I have a small problem with visual flow. I try to execute callout in flow through @InvocableMethod but before this callout, I do update a record(standard update action in Visual flow not in apex code(...
0
votes
0answers
57 views

Test.setMock working in Scratch org but not in sandbox Org

We have batch class used to make an API callout and doing Opportunity upsert DML operation in the Start method. Based on the opportunity's return value, we are making another API callout and doing ...
0
votes
1answer
48 views

Two inserts in one trigger casues the second insert to fail

I have a triggerHandler on the Opportunity object which inserts other objects on afterInsert if it meets the criteria (Opportunity Line Item and Payment). The objects are added to a list before ...
0
votes
0answers
25 views

Wrong DML process, update old values

I have updated one object records with wrong SOQL, how can I set all values as previous?
0
votes
0answers
2k views

NO_APPLICABLE_PROCESS, No applicable approval process was found, yet the criteria is met, no code change in years

Having an odd issue in our prod org recently. Code and approval items haven't changed, yet for some reason after our last monthly release we've been getting the no_applicable_process error here. The ...
0
votes
0answers
70 views

Test Classes: MIXED_DML_OPERATION

Via Process Builder, Is there anything I can do in my process that could stop this from occurring? Error Message: System.EmailException: SendEmail failed. First exception on row 0; first error: ...
0
votes
1answer
591 views

Org Data Update just after the sandbox refresh in FullCopy Sandbox

Our requirement is to update customer's email ID and Phone# to an invalid value in FullCopy sandbox during the sandbox refresh. Using PostSandbox refresh apex class we are updating the User email and ...
0
votes
0answers
128 views

Is it possible to do two DML operations in a single trigger?

I have a custom object called Junction__c with lookups to Custom__c, and Case. In the data model, Custom__c is also a child of Case. There is a validation rule to ensure that any Custom__c record ...
0
votes
1answer
369 views

Mixed_DML_Operation for one User Update method, but not another. Unclear why

I have a Contact Trigger Handler that, after update, checks to see if some fields (Email or Team) were changed, and if they were, it updates the fields on the Contact's Community User record. These ...
0
votes
1answer
50 views

DML result refresh

When I click button, method's setToApprove() action is beginning. But first lines of method when terf_mr_status='approved' and terf_mr_approveddate=TODAY_VALUE doesn't appears inside of generated pdf ...
0
votes
0answers
1k views

How to Add Records From a Lightning Datatable To a Group

I have two Objects PDCN and PDCN Group. I have created a junction Object PDCNJunc also with Master-Detail Relationship to both PDCN and PDCN Group. There is a lightning datatable which shows list of ...
0
votes
0answers
22 views

Updating a value in the list to be updated before and after the dml operation

Im trying to update child record in parent after trigger, where i need to update this child's boolean (MA_Campaign_Qty_Boolean__c) as part of restricting some validation in child's trigger for this ...
0
votes
1answer
59 views

Allow the insert of Custom Records even if some of them fail as duplicates

I want to ignore a bunch of records (Custom settings in fact) and want the transaction to ignore Duplicate errors. All other errors should make the insert fail. If a duplicate exists simply skip the ...