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.

61 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
20
votes
1answer
391 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
138 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
140 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
676 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
297 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
86 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
222 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
95 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
42 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
30 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
1answer
519 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 ...
2
votes
0answers
869 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
98 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
2answers
61 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
2answers
1k 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
0answers
35 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
23 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
147 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
294 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
641 views

Update list values in an input text field

I have below code to update the input text field value for OUTCOME field from the User. My list update is failing to happen without throwing any exception. Please can someone help me here? My ...
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
35 views

DML operation inside a loop

I need to make an apex class that needs to upsert hierarchically three times the same object. Currently, the only way I found to do this was this way: private void upsertLevels() { for(List<...
0
votes
1answer
38 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
1answer
34 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
22 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
37 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
24 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
560 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
47 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
178 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
60 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
110 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
33 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
674 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
813 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
41 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
198 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
129 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
366 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
1answer
39 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
135 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
393 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
162 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
106 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
730 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 ...