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.

58 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
20
votes
1answer
353 views

Email value is saved without parentheses (label) when using DML

When an email contains a label enclosed in parentheses, the value can be saved as typed in via SF UI. (Note: the email value "as is" is only seen when in Edit mode.) However, when the record is saved ...
6
votes
0answers
124 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
114 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
565 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
291 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
44 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
83 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: ...
3
votes
0answers
144 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 ...
3
votes
0answers
87 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 ...
2
votes
0answers
36 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
28 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
822 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
97 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
31 views

Prevent parallel executions of flow element

I have a screen flow that is included in a lightning record page. At some point it executes a callout to an external system. The scenario that I would need to avoid is to have multiple users open the ...
1
vote
2answers
51 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
1answer
719 views

Error creating CPQ - SBQQ__QuoteLine__c Object

I am trying to test a controller that I have written which queries SBQQ__QuoteLine__c objects. I am running into an error which is preventing me from inserting the object during the @TestSetup method. ...
1
vote
1answer
376 views

In test class Topic and Topic assignment creation isnot working

Iam creating dummy records for Topic and its assignment.Topic is creating successfully Topic assignment shows error Below error: Failed to assign topic to null. Please ensure you have permissions ...
1
vote
0answers
27 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
22 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
138 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
289 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
22 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
23 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
357 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
38 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
98 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
46 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
76 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
28 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
485 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
1answer
585 views

Edit properties of a Visualforce Email Template in apex so the email sent through Messaging.sendEmail() will have the most recent data in it

I have a visualforce email template that displays the list of Opportunity records that are populated using a visualforce component. I'm using this email template in a schedulable class. The HTML ...
0
votes
0answers
21 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
36 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 ...
0
votes
1answer
170 views

Mixed DML Operation - creating Resource via Flow

I have a Flow where I create a User and a resource, related to that user, the object resource is managed by Field Service Lightning Package from Salesforce. The Flow itself seems to work fine, except ...
0
votes
1answer
119 views

How can I find out what fields made my upsert fail?

I'm trying to upsert some records. I use Database.upsert. If the failure is related to a duplicate value (external ids that have to be unique) I need to know what fields are duplicate and clear (...
0
votes
1answer
304 views

Deleting all public groups from Org

We have an utility which imports all data from one org to another, this results in creating public groups every time import operation is carried out. Is there any way we can perform delete operation ...
0
votes
2answers
1k views

Error in apex class : System.LimitException: Too many DML rows: 10001

While I am trying to perform an upsert, I am getting this error : System.LimitException: Too many DML rows: 10001 at the line where the upsert statement is written. Code snippet : public class ...
0
votes
1answer
35 views

Is CorsWhitelistEntry insertable/updatable through APEX/DML?

CorsWhitelistEntry cors = new CorsWhitelistEntry(); cors.UrlPattern = 'sdfsdf.com'; insert cors; Wherever I try the above (or any other DML operation), I get an error message: DML operation ... ...
0
votes
1answer
104 views

Multiple DML operations in on update trigger

In an update trigger on parent object I need to do insert/update/delete on child object depending on criteria in parent object. insert and update works as required. but when delete error thrown as ...
0
votes
1answer
297 views

I want send email alert to a public group every week with a html email template in apex class

but the time of setting template in my apex target object id is required and this block accept only 15 digit id so how can i retive ever member user id global class EmailSenderfriday implements ...
0
votes
0answers
146 views

Updating OpportunityLineItem always results in INVALID_CROSS_REFERENCE_KEY

Exact error that I'm receiving: System.DmlException: Update failed. First exception on row 0 with id 00kO0000006gU4fIAE; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []...
0
votes
1answer
101 views

insert and updat unittest not covering. adderror why?

Why is my catch not working on the adderror on contentversion see: trigger NoteOnContentversion on ContentVersion (before insert, before update) { for (ContentVersion c : Trigger.new) { ...
0
votes
2answers
21 views

How to edit (and save) record after confirming that it has been inserted/upserted?

This NOT a trigger. This is a VF page controller. I think you should use try-catch blocks but I'm not sure whats the best practice for that. Should I put in all the code in the try block? Like this :...
0
votes
1answer
18 views

bulkification issue for insert operation of attachment

I am getting bulkification issue on "insert at".Not able to understand why there is bulkification issue.Below is my code. public static Attachment addAttach(Attachment at) { try { ...
0
votes
1answer
562 views

Confused about OrderProducts, OrderItems, and Products when making orders in test class

I'm making a test class that creates 5 orders and upon insert, I get the error that you need to add products to orders. I've got... List<Product2> clothProds = [SELECT Id FROM Product2 WHERE ...
0
votes
0answers
57 views

Trigger is working fine for inserting records but not working on update of records

I have written a trigger to update one lookup field of invoice with salesquota object id.This triggers work fine when i am inserting records.But when i try to update records with few changes it is not ...
0
votes
1answer
165 views

Insert Operation using Map Instead of List

How can I implement insert operation using map collection instead of list? I've created a conference scheduling app wherein upon selecting a certain student from a picklist, a table containing ...
0
votes
0answers
91 views

Able to make isactive = false for such users who are manager of some other users

I am able to make isactive=false for such users who are manager of some other users.As per salesforce funtionality i should not be able to make isactive=false using DML as it will throw dependency ...
0
votes
1answer
130 views

Successful DML operation not getting updated in database

I am using below code for batch update : List<Database.SaveResult> updateResults; updateResults = Database.update(listUserDeactivate, false); System.debug('value of users for ...
0
votes
1answer
89 views

Param values are not being passed to the custom controller using commandbutton

Need pro's help. Below are my code snippets. This is what I have tried I have initialized the object Event_Request__c {get; set;} in my controller class. I have created a public method to update the ...