Questions tagged [dmlexception]
Any problem with a DML statement, such as an insert statement missing a required field on a record.
177 questions
0 votes
0 answers
36 views
Unittests fail after activating PersonAccounts
After activating PersonAccounts and running all tests, i run into the following error: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, ...
-2 votes
1 answer
176 views
Updating Account returns DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>
I have a function in an Apex Class which is called with an HTTP Post via a REST Api Apex class. One of the things it does is to update Account records (selected with a SOQL query in the failing method)...
0 votes
2 answers
168 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....
-1 votes
1 answer
449 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 [...
2 votes
1 answer
338 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 ...
1 vote
1 answer
63 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: ...
0 votes
0 answers
72 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 ...
9 votes
2 answers
2k 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 ...
-1 votes
1 answer
73 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 +...
0 votes
1 answer
198 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, ...
2 votes
0 answers
256 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 ...
0 votes
1 answer
2k 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 ...
0 votes
1 answer
96 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 ...
0 votes
1 answer
748 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 ...
0 votes
1 answer
2k 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 ...