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
2
votes
1answer
59 views

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY error thrown in random places

Recently I've started getting error message: System.DmlException: Upsert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, Access to entity 'AIInsightValue'...
0
votes
0answers
26 views

Restrict user deactivation if Account is owned by the user and send an Email with details

please help. I am new to SFDC please help. Requirement: Restrict user deactivation if Account is owned by the user and send an Email with details. Trigger on user object: trigger userTrigger on ...
1
vote
1answer
47 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 ...
0
votes
1answer
22 views

when running test class, encountering runAs() issues with user having insufficient access to upload resume

I am encountering an issue with running my test class as a made-up user. It seems like I have insufficient access to uploading files onto the org, anyone would be able to point me in the right ...
0
votes
1answer
62 views

how to Unit Test a failure to deactivate a user (DML failure)

/** * Restful resource Patch (update record) request passes user federation Identifier * @param emailId */ @HttpPatch global static List<ResponseWrapper> DeactivateUser_Restful_Ctl(string ...
1
vote
0answers
55 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 ...
0
votes
1answer
76 views

Throw an exception in Apex if attachment is null

I have a Visualforce form that takes attachments of which I need to make required in order for the user to proceed to the next screen. Since the record doesn't get inserted until the end of the multi-...
0
votes
1answer
35 views

How to get the inner exception?

So I catch a DMLException which is caused by a custom exception from a managed package, now how can I get that custom exception? Here is the log: 18:33:24.391 EXECUTION_STARTED ... 18:33:25.710 ...
1
vote
1answer
71 views

ContentDistribution FIELD_INTEGRITY_EXCEPTION

I'm trying to insert a record to ContentDistribution object using the following: Here is the doc says: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/...
0
votes
1answer
53 views

Writing efficient code

I would like to understand the difference between snippet 1 and snippet 2. In snippet 1 I get a DML rows limit exception whereas in snippet 2, I don't get any exception. What makes snippet 2 not throw ...
0
votes
0answers
23 views

DmlExecutionException: Update failed.first error: DUPLICATE_VALUE, duplicate value found

I understand DUPLICATE_VALUE DML Exception on insert of a record which is already existing However, I am observing this issue for an update on the existing record. When I find an existing contact ...
0
votes
1answer
172 views

How to avoid MIXED dml Exception in update operation? [closed]

I got System.DmlException in update operation. Can anyone please check the below code and help me to resolve the exception. I have tried to solve it for the last two days but I couldn't find a ...
1
vote
1answer
111 views

MIXED_DML_OPERATION : Can not insert a user record from account trigger even when User Role is null

I am trying to create a community user in an after update trigger of account. I am setting the UserRoleId = null but still am getting MIXED_DML_OPERATION exception. As per documentation: You can ...
0
votes
1answer
53 views

DataLoader on contacts causing System.LimitException: Too many DML statements: 151

I have a trigger on contacts that is causing DML errors and I'm not sure where the problem is as I only have one update on a list. This is occurring when I am using the Data loader to update about 30k ...
1
vote
1answer
44 views

How do I take out the DML statements out of the loop? [duplicate]

I am new to apex, I've achieved the basic working code of what I had to, in java. But now I am told that I cant do DML statements or queries inside loops. Any help/explanation as to how I could I do ...
0
votes
0answers
271 views

Database.convertLead() - when validation exception fires, it is not possible to catch it

I've got implemented code where I do automatic Lead conversion. The conversion works fine, but there are some custom validation rules in the org. When these validation rules fire, an ugly message is ...
0
votes
1answer
27 views

UNABLE_TO_LOCK_ROW while running two or more tests

I'm trying to run two different test classes, but every time I do this, one of them shows error on the setup method, right in the line where I'm going to insert a new user. Is there a way to fix this? ...
0
votes
1answer
665 views

Getting the following error INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY for a site guest user

So I know similar questions has been asked before, but I couldn't find a solution using the following links: Link1, Link2, Link3 (and more) The situation is as follows. So I have a form (a visualforce ...
1
vote
1answer
27 views

I'm trying to insert new record but it gives error as Line: 7, Column: 1 System.StringException: Invalid id: objcus.id

Apex_Customer__c objcus=new Apex_Customer__c(); objcus.Name='Test ABC'; insert objcus;//it will creat new customer records Apex_Invoice__c objnewinvoice=new Apex_Invoice__c(); objnewinvoice....
2
votes
1answer
112 views

Dynamically Insert parent child records in a single DML

I'm trying to insert contact and account records in a single DML. In my case I don't want to use the . operator Instead, I'm using the put operator to insert records. Account acc=new Account(Name='...
0
votes
2answers
1k views

MIXED_DML_OPERATION, DML operation on setup object is not permitted Contact User

Hi i have a problem cuz I'm trying do sth like below: this method has adnotation AuraEnabled Contact contact = getContact((Id)contactId); contact.Inactive__c = true; User user = getUserByContactId(...
0
votes
1answer
2k views

Apex Superbadge Automation Test Failure - System.DmlException: INSERT FAILED and UPDATE FAILED

Working on the Apex superbadge challenges and got stuck on Challenge 4 - "Test automation logic". I am getting the following error: Although the test coverage is 100% and is working without any ...
0
votes
0answers
209 views

Self Lookup restriction not respected for a lookup field

I have 2 lookup fields to Opportunity in Opportunity Object. Parent Opportunity and Ultimate Parent Opportunity. I cannot update the parent to itself, which gives the expected error below You ...
-1
votes
2answers
42 views

Can't cover DMLException with my test

I'm trying to cover my Exceptionm But I don't know. how to do this. When I try to insert a record without Required fields, I get the System.DmlException: Insert failed. First exception on row 0; first ...
0
votes
2answers
852 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
65 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:...
1
vote
3answers
585 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
366 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
29 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 ...
2
votes
1answer
2k 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
865 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
241 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
272 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
2answers
144 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
1k 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
2k 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
1k 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
98 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
1answer
1k 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
341 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
1k 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
51 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
701 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
74 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
98 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
331 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
118 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
2k 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
152 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
114 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 ...