Questions tagged [dmlexception]
Any problem with a DML statement, such as an insert statement missing a required field on a record.
170
questions
0
votes
1
answer
47
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, ...
1
vote
0
answers
75
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
199
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
56
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
74
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
0
answers
42
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:...
0
votes
1
answer
70
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 ...
0
votes
0
answers
40
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 ...
0
votes
1
answer
122
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 ...
1
vote
1
answer
62
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(){
...
0
votes
1
answer
65
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 ...
0
votes
0
answers
92
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 ...
0
votes
1
answer
782
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 ...
0
votes
2
answers
2k
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: ...
0
votes
2
answers
75
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....
1
vote
0
answers
251
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 ...
0
votes
0
answers
63
views
DML Exception not being caught
ClassA {
Method1() {
Method2();
}
Method2() {
ClassB.Method3();
}
}
ClassB {
Method3() {
//Failing DML Operation
}
}
How come I can only ...
-1
votes
1
answer
312
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++)
...
0
votes
1
answer
160
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.
...
1
vote
1
answer
1k
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()...
1
vote
1
answer
777
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 ...
0
votes
1
answer
209
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=&...
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 ...
0
votes
1
answer
241
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(...
2
votes
1
answer
411
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'...
1
vote
1
answer
501
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 ...
1
vote
1
answer
144
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 ...
1
vote
1
answer
343
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 ...
2
votes
1
answer
653
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
1
answer
708
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
1
answer
227
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
1
answer
493
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
1
answer
71
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
0
answers
102
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
1
answer
262
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
1
answer
404
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
1
answer
229
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
1
answer
218
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
0
answers
937
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
1
answer
69
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
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 ...
1
vote
1
answer
47
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
1
answer
380
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
2
answers
6k
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
0
answers
400
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
2
answers
106
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
2
answers
4k
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
1
answer
359
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
3
answers
1k
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
2
answers
525
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>: ...