Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs

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
2 answers
35 views

DMLException method getFieldNames() does not exist

I try to implement insert as user and catch fields that user has no access to them but I face with problem that method does not exist. try { update as user items; } catch(DMLException e) { System....
Ярослав Пажух's user avatar
-1 votes
1 answer
32 views

Issue with updating person account error: REQUIRED_FIELD_MISSING, missing required field: [ACCOUNT.NAME]

I am facing a strange issue in salesforce org. This org has Personaccount enabled. Whenever a user go to person account page and tries to edit it user is getting error Required field is missing [...
Manjot Singh's user avatar
  • 3,516
2 votes
1 answer
62 views

Insert as User fails during test class

We have a class created with sharing that inserts a record as a user. I've created a test class and added a user, along with the related PermissionSet assigned to that user. However, when I run the ...
OztheWiz's user avatar
1 vote
1 answer
27 views

Compound Field Access Error

I am trying to assign value to compound field(FirstName) for specific record type. But got an error. "System.DmlException: Insert failed. First exception on row 0; first error: ...
Muhammad Jahanzaib Tariq's user avatar
0 votes
0 answers
46 views

How to make a callout after DML?

I'm making an api callout from einstein bot and waiting for the response to show in the chatbot the isssue is that the api needs a token that expires for every six hours to get resolve that I'm ...
mine_username's user avatar
9 votes
2 answers
660 views

Executing SOQL with User Mode and then DML with user Mode causing Exception

I couldn't find if SOQL and DML become interlinked when using WITH USER_MODE with SOQL and DML both in single transaction. I've below sample code to be triggered on a button from an LWC: @AuraEnabled ...
VarunC's user avatar
  • 5,950
-1 votes
1 answer
48 views

Code coverage and DMLException - How to enter Exception?

I insert lists that are created from pre-existing data. In my @testSetup I create the mockup but it's 'impossible' to enter the DMLException when trying to achieve 100% code coverage. This is my code +...
Alexis MASSON's user avatar
0 votes
1 answer
58 views

FATAL_ERROR System.SObjectException: Field is not writeable: Monthly_Finance__c.Project__c

public with sharing class CSVController { @AuraEnabled public static string loadCSVData(Id contentDocumentId, string fileType){ ContentVersion contentVersionObj = [ SELECT Id, ...
utkarsh singh's user avatar
1 vote
0 answers
173 views

How to handle DML exceptions in apex class WITH USER_MODE?

I'm trying to do a DML with user mode in apiVersion 58.0. I got "DML Exception" while inserting records without field permission and I got "SecurityException" while inserting ...
Senthil Kumar's user avatar
0 votes
1 answer
804 views

Insert failed. REQUIRED_FIELD_MISSING, Required fields are missing: [External Data Source]: [External Data Source]

I am trying to store the attachments from an incoming email to the ContenDocument, ContentVersion, and ContentDocumentLink objects. Below is the method/function: @testVisible private static void ...
Marjan's user avatar
  • 15
0 votes
1 answer
69 views

Why is my trigger not updating the field?

I have a custom object and it's related history by activating the history tracking of its field. However, I don't really understand why it's not updating my custom object field? Can someone please ...
ratRiot01's user avatar
0 votes
1 answer
502 views

After Update and Insert Trigger with Future Method Causing DMLException

I'm trying to update a field on the account field with a trigger using after insert and update. I am using a future method to make a callout to a rest API to get the rate of BTC in USD. My issue is ...
Carraig's user avatar
0 votes
0 answers
47 views

Update an Opportunity from a future callout method

I have a future method that posts data to an API, and IF the response2.getStatusCode() == 200, I would like to update a field on the opportunity. However, I get this error message: System.DmlException:...
potato46's user avatar
0 votes
1 answer
686 views

Unit Test Error Using System Admin Profile: INVALID_FIELD_FOR_INSERT_UPDATE, Unable to create/update fields: Name. Please check the security settings

I'm getting this error when creating an Account inside a Test class. I'm using the System Admin profile to execute the tests, and this profile has permission to edit the Account Name field (mentioned ...
Emmanuel_M's user avatar
0 votes
0 answers
52 views

Getting INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST while creating a record for CareRequestExtension

All. I am trying to create a record for CareRequestExtension via apex. While creating the record I am providing non-existing values to some picklist fields of CareRequestExtension. For some picklist ...
Vishwajeet Singh Bhadoria's user avatar
0 votes
1 answer
299 views

Flow: MIXED_DML_OPERATION: DML operation

I am trying to automatically add a User's Default Team to an Account record when a Checkbox field on the Account record is checked to 'True'. I am using a Flow for this but am getting the following ...
sp2's user avatar
  • 77
1 vote
1 answer
87 views

DML currently not allowed after attempting to insert a record after a callout

In my visualforce page, I have defined an Apex method from my controller to execute with the "action" attribute of the page. This is the method: public void verificarAdjuntos(){ ...
joacoiudica's user avatar
0 votes
1 answer
78 views

How to Force an Apex Sharing Recalculation DML Exception?

I have implemented the following Sharing Recalculation class from the Documentation try { // Delete the existing sharing records. // This allows new sharing records to be ...
Chris's user avatar
  • 5
0 votes
0 answers
162 views

Too many DML statements: 1 LWC

Hello everybody I am working on a LWC form that gather information from the user and validates it and create a new record with the data in the form. The problem is that I am getting a Too many DML ...
user avatar
0 votes
1 answer
2k views

too many dml rows: 10001 when calling batch apex from Trigger

I am calling a batch class from trigger after update. Eg: database.executeBatch(new myTestBatch(trigger.newMap.keySet()),200); But it gives Too many dml rows:10001. This is my batch class. global ...
sThirumagal93's user avatar
0 votes
2 answers
3k views

System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

I'm getting the below error while running the test class. Can anyone help on this please? Error : System.DmlException: Insert failed. First exception on row 0 with id a057h000002BqVUAA0; first error: ...
user avatar
0 votes
2 answers
96 views

Hi all, I am writing a trigger handler that needs to update the owner of a record to a specific user, but I am getting a DMLexception error

I am getting the following error. I am not trying to update the Name field, so I am not sure why I am getting this error. Thank you for your help in advance :)! EXCEPTION_THROWN [10]|System....
Tristan's user avatar
  • 13
1 vote
0 answers
276 views

Condition membership of experience site based on permission set for users created with createUser handler code

We have created handler code which works great for a community when the community is set to allow membership based on the profile that is also assigned by the handler code. We have a requirement ...
Jake Durell's user avatar
0 votes
0 answers
127 views

DML Exception not being caught

ClassA { Method1() { Method2(); } Method2() { ClassB.Method3(); } } ClassB { Method3() { //Failing DML Operation } } How come I can only ...
Marga's user avatar
  • 23
-1 votes
1 answer
404 views

I am unable to insert 10000 records. Getting Too man query rows error

public class CreateBulkAccounts { @future Public static void method1() { List<Account> acList = new List<Account>(); for(integer i=0; i<10000; i++) ...
narojoc807's user avatar
0 votes
1 answer
209 views

Insert JournalType DUPLICATE_VALUE exception in Loyalty cloud test class

We are working with Salesforce Loyalty cloud. In one of our test classes, we are setting up data, where we try to insert some records of the JournalType standard object coming with Loyalty cloud. ...
Gabriel Serrano Salas's user avatar
1 vote
1 answer
2k views

Metadata cannot be deployed from within a test [duplicate]

When trying to insert a custom metadata record within the test it gives me the following error @IsTest public class Object_1TriggerTest { @IsTest public static void Load_field_1_from_metadata()...
Ernesto Truyen's user avatar
1 vote
1 answer
1k views

LIMIT_EXCEEDED, limit exceeded: [] when creating Community User

Suddenly getting the following error: System.DmlException: Insert failed. First exception on row 0; first error: LIMIT_EXCEEDED, limit exceeded: [] when trying to insert a Community User via apex ...
Max's user avatar
  • 101
0 votes
1 answer
259 views

Too many DML statements: 1

im working with LWC, creating a button to upload files. but, when i click submit button console shows that error: "Too many DML statements: 1" <template> <lightning-card title=&...
Martin Gamboa's user avatar
0 votes
2 answers
1k views

Handling FIELD_INTEGRITY_EXCEPTION with try catch and logging errors

I have got an apex trigger that sometimes errors with System.DmlException: Update failed. First exception on row 0 with id 00Q0800000fhnM2EAI; first error: FIELD_INTEGRITY_EXCEPTION The reasons for ...
chiapa's user avatar
  • 103
0 votes
1 answer
384 views

Create an account every time a contact is created (and the account is not existing in the Org)

I have a requirement to create a new account(if the entered account doesn't exist already) every time a contact is created/edited from ETL (The ETL profile user) public static void createAutoVendor(...
sambit nayak's user avatar
2 votes
1 answer
666 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'...
ItSpeezy's user avatar
1 vote
1 answer
661 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 ...
erik.ohlin's user avatar
1 vote
1 answer
230 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 ...
Bartek 's user avatar
1 vote
1 answer
403 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 ...
ensir's user avatar
  • 383
2 votes
1 answer
853 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 ...
Mike's user avatar
  • 1,199
0 votes
1 answer
891 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-...
SpicyPat's user avatar
0 votes
1 answer
304 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 ...
Movsar Bekaev's user avatar
1 vote
1 answer
732 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/...
Nick's user avatar
  • 7,022
0 votes
1 answer
76 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 ...
Krishnamurthy's user avatar
0 votes
0 answers
150 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 ...
Smitha's user avatar
  • 1
0 votes
1 answer
284 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 ...
Raghu's user avatar
  • 1
1 vote
1 answer
479 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 ...
Sarang's user avatar
  • 2,586
0 votes
1 answer
265 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 ...
Scott B's user avatar
  • 27
1 vote
1 answer
264 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 ...
manb's user avatar
  • 95
0 votes
0 answers
1k 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 ...
David's user avatar
  • 1
0 votes
1 answer
88 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? ...
César Villanueva's user avatar
0 votes
2 answers
1k 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 ...
fooiey's user avatar
  • 103
1 vote
1 answer
48 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....
user84897's user avatar
2 votes
1 answer
439 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='...
Krishnan Mishra's user avatar