Questions tagged [dmlexception]

Any problem with a DML statement, such as an insert statement missing a required field on a record.

Filter by
Sorted by
Tagged with
0
votes
2answers
48 views

Getting CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY error when testing Apex

I'm re-writing unit tests for the Apex Specialist superbadge (yes, re-writing, I successfully completed the superbadge a couple of days ago, and found a few bugs while playing around today, decided to ...
0
votes
1answer
20 views

How to get the root cause of an unhandled trigger error?

If I have some code doing DML which runs a trigger, and then that trigger throws an unhandled exception, how can I get the real cause of the problem? For example, suppose I have a really dumb trigger:...
0
votes
0answers
32 views

Getting “ duplicate value found: Booking_Id__c duplicates value on record with id ” '' Error

I deployed changes from dev org to full sandbox successfully by ANT. Now I am getting Error as "Booking_Id__c duplicates value on record with id: 'ID' ERROR" while creating the new record. Previously ...
1
vote
3answers
47 views

How to cover Catch block in ApexUnitTest class when using DML statement in try body

I have some apex code, where I try to upsert a list of records: try { upsert recordList Accounts; } catch (DmlException e) { //do a loooot of stuff in order to provide a proper ...
4
votes
2answers
129 views

Scratch Org: DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>: []

I and my whole team encounter this error while inserting some data into a new Scratch Org. DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>: ...
0
votes
1answer
20 views

Delete Scheduled Jobs using Apex in one go

I have More than 2500 Scheduled Jobs and i want to delete them but the issue is when i try system.abortJobId(jobId); on a list of job id which i fetched using soql it says not more than 150 DML ...
0
votes
1answer
20 views

INSUFFICIENT_ACCESS_OR_READONLY when editing an Order

When editing an Order (either through the UI or via an Apex program that does DML), I get First exception on row 0 with id 801.... INSUFFICIENT_ACCESS_OR_READONLY insufficient access rights on ...
0
votes
2answers
51 views

Update failed. First exception on row 0 with id ******; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, LeadTrigger: maximum trigger depth exceeded

Error on Line 154: Update failed. First exception on row 0 with id ******; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, LeadTrigger: maximum trigger depth exceeded public class ...
0
votes
1answer
29 views

Alternatives to add error

I've been using addError() to prevent dml insertions of records that don't accomplish with the validation rule. The problem is that using that, if i insert a list of 100 records and one fails, the ...
1
vote
1answer
45 views

Test Class Failing : DML Exception

I'm having trouble getting my test class to pass tests. Getting: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Select from Add ...
0
votes
0answers
28 views

Upsert Fails but there does not seem to be any validation rules

Getting the error below but the rental object does not have any validation rules. try { upsert ren; createbill(ren); } catch (DMLException exc) { System.debug('exc '+exc.getMessage()); } ...
0
votes
2answers
29 views

How to cater opportunity insertion in my TEST class

I have a method in APEX class that does variety of checks via If else conditions with some SOQL statements. I created test data(Accounts, custom object records) to test the SOQL statements and it ...
2
votes
1answer
241 views

Getting 'FATAL_ERROR System.TypeException: DML operation INSERT not allowed on Group' on Apex Trigger

I am getting: "FATAL_ERROR|System.TypeException: DML operation INSERT not allowed on Group" error on an apex trigger (line 43) when I am logging in as any other user except System Admin. I am ...
4
votes
1answer
413 views

System.DmlException: Insert failed. STRING_TOO_LONG, Body: data value too large

I have a string which has a length of 89308 which represents a PDF document. I want to store this data into a ContentVersion like this: ContentVersion contentVersion = new ContentVersion( ...
8
votes
3answers
317 views

How to Aura Handle multiple DmlExceptions

How should I handle multiple DmlException messages when using AuraHandledException inside an Apex Controller. If I do this: try { upsert value; } catch(DmlException e) { throw new ...
0
votes
1answer
56 views

List.clear() not emptying my List

The project that I am working on has an API endpoint that is meant to upload a large number of records into three different tables: Careers, Degrees, and CareerDegreeRelationships. The endpoint is ...
0
votes
0answers
147 views

Exception method getStackTraceString is empty ()

I'm sending any errors that our try/catch blocks catch to Slack and for some reason all the Exception info is filled out apart from the getStackTraceString method. It's a method within a class: try {...
0
votes
1answer
91 views

Unable to merge contacts (fails to update field)

I use the native merge functionality to glue two duplicate contacts together programmatically: merge target source; Yet this invokes the following error: 12:06:49:251 USER_DEBUG [46]|DEBUG|DML_e: ...
0
votes
1answer
381 views

Need help with this strange error: DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>: []

I have an apex code which identifies users who have subscribed to an Account( basically followed an Account for any chatter posts ).The code then subscribes these users to the related Opportunities of ...
0
votes
1answer
34 views

How can I allow a user with the 'Partner: Executive Full License' to edit their own contact?

I have a use case where some Apex code will need to run as a user with this profile. I am updating some fields in this code and then performing an update on the contact that's associated with this ...
1
vote
1answer
167 views

How to process more than 10K records from batch in one Transaction?

we have a functionality as following: on VF page we define some criteria say e.g Account Name = Nachiket and some other configurations. configuration details we store in custom object say Custom ...
0
votes
1answer
55 views

UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record during Insert

Good day Everyone, I know there are lots of questions which is similar with my question. But I still post this because I did not find any case which is similar with mine. I am working with some ...
-1
votes
2answers
52 views

Can some one tell how setup object effect non setup object exact into one transaction?

In this case example please explain .... what exactly happening if i am not calling future method. trigger Automatecontact on Account(after insert) { List<contact> lc = new List<contact>(...
0
votes
1answer
100 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
49 views

Optimal number of records per batch

I have a problem executing a batch in some limit cases that i want to cover to avoid future concerns. The scenario is the following: My batch works on n(reasonable high number) records of the same ...
2
votes
1answer
859 views

How to display Trigger addError in Salesforce Lightning using AuraException

Background I have a before insert trigger which returns an error: myObject.addError('Helpful Message'); Which I want to catch and display gracefully in my lightning component. My Apex controller ...
0
votes
1answer
56 views

Attempt to de-reference null object (Custom File Import)

The requirement is to import a tab separated text file and updated the records matching with some statuses then display success to for failure with the list of records. I wrote the following VF and ...
0
votes
1answer
53 views

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY when System.runAs(u) in a test class

I need to create a Patient_Registration__c (which is a Person Account) under a specific user in my test class. Following is my code in the test class: Profile p = [SELECT Id, Name FROM Profile WHERE ...
3
votes
2answers
248 views

Partial Execution within apex function

A customer of mine is seeing partial execution of an Apex Function. In the Function, they need to Insert/Update multiple objects. Insert new Contact(...); ... Insert new Cust_object__c(...); In the ...
0
votes
2answers
275 views

Too many DML rows: 10001 when deleting records in Batch class start methods

We upload Revenue Data on monthly basis in our system. For this we have created a Custom Object Revenue__c that stores the information of Revenue Data.We have created a Custom Application where with ...
3
votes
2answers
155 views

How many DML statements will be execute for below code?

Below is the logic/Method i have built to eliminate error while inserting case Object. Consider a example when i try insert case object inside try block, if it is throwing an error while inserting, I ...
0
votes
1answer
113 views

Update Statement fails in test class when run as a community user

I am writing test case to check withdraw application function. It gives the following error on update application statement. System.DmlException: Update failed. First exception on row 0 with id ...
0
votes
1answer
112 views

Can guest user delete custom object records?

I have a custom object which is having look up to Account and contact and few other custom objects. Can users with Guest user License delete such records. I have been trying to delete with an ...
3
votes
1answer
57 views

DMLException handling in a Before trigger context?

I got 99% of the way through refactoring a trigger from "after" to "before" when I noticed one little thing I'd overlooked when judging whether or not to do it: My trigger copies data from "holding ...
0
votes
2answers
799 views

FATAL_ERROR|System.QueryException: List has no rows for assignment to SObject

I am getting FATAL_ERROR|System.QueryException: List has no rows for assignment to SObject. I know that it is because it is not returning any rows in the SOQL query but what I want is that if it ...
3
votes
1answer
236 views

Non-Duplicates are being detected as duplicates

I'm trying to run the following unit test: @IsTest static void testInsertContactWithMultipleDuplicates() { { TriggerManager.allTriggersDisabled = true; Contact dupRecord1 = new ...
1
vote
1answer
301 views

Display error messages from unique field error

We have a unique field on an object, populated by workflow (datestamp + userId), which prevents a user from submitting two records on the same day. I'd like to display an error message on the ...
4
votes
0answers
197 views

Intermittent Process Builder Flow Error - How to troubleshoot with no info?

Background I'm getting a dreaded flow error for one of our test methods that occurs fairly regularly, but not consistently. I've reviewed the debug logs thoroughly, but can't see any obvious way to ...
1
vote
1answer
170 views

How do I mass delete Territory2 records in Apex?

I have a list of Territory2 records. All of them are from the deepest level of my territory hierarchy. When I attempt to save some apex to Salesforce that would delete this list of records, I'm ...
7
votes
1answer
795 views

How to rethrow DmlExceptions as AuraHandledExceptions right

Exception handling in Lightning is a pain. Instead of Lightning showing regular exceptions one has to catch them in code and rethrow them as AuraHandledExceptions as shown below: try { .... ...
5
votes
1answer
239 views

How to get the underlying custom exception from a trigger's DMLException [duplicate]

My question was previously asked but the answer in that case was unrelated. In my case, I have a class that can raise custom exceptions, and the class may be called from trigger context. When that ...
-1
votes
2answers
84 views

DML exception on seemingly not involved object?

Apex trigger TF_UserTrigger caused an unexpected exception, contact your administrator: TF_UserTrigger: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on ...
2
votes
0answers
24 views

Is it possible not to display INSERT FAILED Error in page, when our custom validation error is triggered

We have a visualforce page (Manage Packaged) that saves a record. We added a custom validation using trigger (addError method) to prevent it to save when a certain criteria is met. But when this is ...
1
vote
2answers
210 views

Test fails in destination Org with System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE

I've a test class for a controller which passes in the development Org but not in the destination/sandbox. Here's the error I get System.DmlException: Insert failed. First exception on row 0; first ...
0
votes
2answers
833 views

How to get and rethrow Exception from Database.insert(list, false)

I am inserting record using the allOrNothing = false option to only rollback the transaction when a certain type of error occurs (Goal: Allow the insert of Custom Records even if some of them fail as ...
0
votes
1answer
145 views

Self-reference error during a roll-up summary calculation

Up until this point I was of the belief that roll-up summary operations didn't interfere with custom Apex and were calculated quietly in the backend. However, I am seeing otherwise. Consider the ...
0
votes
1answer
77 views

Handle errors in visualforce table with multiple checkbox [closed]

In the visualforce page, we are binding list of records and the table has Select All checkbox. When selected the records in the page get selected and there we placed a option to open a modal popup to ...
1
vote
1answer
335 views

Updating Contact record after self-registration in Community

In my community I have enabled self-registration option. It works fine, however, I would like to update some fields on the related contact record (e.g. Mailing Address) when the community user is ...
2
votes
1answer
1k views

REQUIRED_FIELD_MISSING & FIELD_INTEGRITY_EXCEPTION on PricebookEntry Insert

I want to use standard price for the Pricebook entry. PricebookEntry pbe = new PricebookEntry(Pricebook2Id='01sN00000002OTsIAM', IsActive=true, Product2Id='01tN0000004JGeuIAG', ...
1
vote
2answers
212 views

Why am I getting duplicate ApexMessages when concatenating string in a try/catch

I have two different approaches for adding an error to my visualforce page. The first approach I am concatenating a string at the end of exception. The second approach I am simply returning the ...