Questions tagged [dml-operations]
Use Data Manipulation Language (DML) statements to insert, update, merge, delete, and restore data in Salesforce.
38
questions
0
votes
2
answers
41
views
AfterInsert caused by: System.FinalException: Record is read-only
I want to update a record that has recently been created.
Trigger:
trigger TTCaseTrigger on Custom_Case__c (after insert) {
if(Trigger.isInsert && Trigger.isAfter){
if(...
0
votes
1
answer
143
views
Not getting access related errors while updating records from LWC and with sharing apex
I am trying to update records which I don't have update access on. I am expecting to get errors for such records but it updating successfully.
my org object owd is public read only and profile access ...
0
votes
0
answers
359
views
Method used in After Insert, After Update and After Delete must fire only when once even though there are multiple DML(Add,update,delete)
I have visualforce page which allows user to perform mixed dml (add/delete/update) on records at once. I have a method(that creates a opportunitylineitem showing the aggregate sum of records) is used ...
1
vote
0
answers
102
views
Lightning component working fine but input data is not getting added to salesforce database
public class CreateLeadcls {
@Auraenabled
public static string createLead(Lead ldObj){
System.debug('Lead::'+ldObj.FirstName);
insert ldObj;
return ldObj.FirstName;
...
1
vote
1
answer
7k
views
Update records in LWC using Apex
I have LWC to show contact records and modal to edit the records, I'm able to fetch records and editing also showing but don't know how to run query to update records, please look into my code, it ...
0
votes
1
answer
720
views
Trying to insert record with master-detail relationship by external id
I have a callout which receives one master object which I map to a Case and upsert base on a field set as External Id. Inside this master object there is a list of child objects which I map to a ...
-2
votes
1
answer
112
views
How to update opportunity records closedate as today using dml statements? [closed]
I am trying to update the all opportunity records close date as today using dml statements. Can anyone please help me
1
vote
0
answers
43
views
Is it possible to POST multiple Tooling SObjects with a single request? [duplicate]
I've seen and tested that I can create or update single records of TraceFlag (for example) using "/tooling/sobjects/SObjectName/".
However, years of working with Salesforce has ingrained in ...
0
votes
2
answers
25
views
Are processes triggered if a field is set to the same value as it held before?
An Apex method is called and updates the StageName field from 'Approved' to 'Documentation.' It completes. A different Apex method is called and 'updates' the StageName field on the same record from '...
-3
votes
1
answer
2k
views
Creating a 100K records in Account salesforce object using apex code [closed]
I am trying to create an 100K Account records in my salesforce org using apex code in developer console, I managed to create till 1000 by this apex code.
List<Account> list1 = new List<...
0
votes
1
answer
809
views
Updating objects with SOAP API
I've set up a chat for my Salesforce Org and I want to change the chat capacity through code. From the Salesforce documentation (see documentation) it is possible to update the PresenceUserConfig. I ...
0
votes
1
answer
677
views
Writing test class to change Inactive User to Queue
I'm a beginner APEX developer in a bit of a tricky spot.
As we know, leads get assigned to sellers. However, sellers get fired from time to time causing them to become inactive users. The issue then ...
0
votes
0
answers
182
views
Trying to insert 2 records in 2 custom objects which AREN'T in a Relationship via Lightning Aura Component
I am trying to create a record in 2 objects at a time.
Object 1 = Guest_Master__c Guest ; its fields =Guest_First_Name__c, Guest_last_name__c, Guest_email__c, Guest_phone__c.
Object 2 = ...
0
votes
0
answers
1k
views
Batch Apex Class with HTTPCallout to Insert New or Update existing records
I'm struggling to make this work. I'm a very beginner developer and really need some help.
I need to connect to an external system, get the Contacts from a list and create new Leads in Salesforce. In ...
0
votes
0
answers
138
views
Transaction Security Policy - Stop connectors(Data loader, Excel connectors, workbench, etc.. ) to do DML in salesforce
I got a requirement where I need to stop my users to perform the update, insert, and upset from any connector(Excel connector, workbench, data loader, etc..) even if they have access in the profile.
I ...
0
votes
1
answer
1k
views
Upsert DML Operation
Consider the below code. I thought the way upsert DML works is that if it sees that there is a new record with matching key (here in this case there is already an account with Name = Acme and ...
1
vote
1
answer
267
views
DML in trigger succeeds, but records are not created/available
We have a Trigger Handler which calls on "after update" a method "CreateNewRecords".
public without sharing class sObjectTriggerHandler {
public static void handleAfterUpdate(...
1
vote
1
answer
431
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
2
answers
533
views
Audit log of who/what creates new records
There are concurrent creations of multiple records happening in the org. We want to track the creation of record(standard/custom sObject). We also want to see which user is creating/updating that ...
0
votes
1
answer
178
views
Database Apex class benefits [closed]
The pros and cons of using Database apex class oposite to SOQL direct queries or DML - in which cases we should use database class?
2
votes
2
answers
1k
views
DML operations in the Apex callback method
An apex method that returns a continuation object can’t perform DML. The solution given by the Salesforce developer documentation is the “perform DML operations in the Apex callback method”.
https://...
0
votes
2
answers
1k
views
do I need to update or insert a list, set or map in testclass
When ik create a list, set or map and add records to these do I need to update / insert after adding records. I did a test system debug on a testclass with only a return.
My debug returns a list with ...
-2
votes
3
answers
3k
views
Can I throw custom exception inside a loop?
I've created a custom exception class by extending Exception {}
my question is, can I throw a custom exception inside a loop. does Apex consider throwing a custom exception as a DML operation
Below ...
0
votes
1
answer
951
views
Merge Contacts through API Endpoint (3rd Party App?)
My understanding (after googling this intermittently throughout the last 12 months and vainly hoping the answer to be different each time) is that there is no Salesforce API Endpoint that a user could ...
0
votes
1
answer
2k
views
How do I advoid mixed dml operation creating user for community
I am trying to create a list of contacts and add these to the community as users. I keep getting the error:
MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have ...
-1
votes
2
answers
237
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 ...
1
vote
2
answers
804
views
More than 100 Api Calls and Insertion of More Than 1000 Records
I have an apex class that is going to make more than 100 api calls to an external resource to get more than 10000 records for insertion into Salesforce.
What should I use to get around this?
I ...
0
votes
1
answer
1k
views
Before Insert Trigger Not Deleting The records
Here's the scenario:
I've a custom object (ObjectA__c) with only one custom field Email_Address__c (which can be unique).
Now I would be inserting new records using Data Loader such that:
1) If ...
2
votes
2
answers
897
views
DML Statement vs. Database method with true parameter?
Database methods with a true parameter will work same as DML statements. It won't allow partial DML operation in Apex
Why are we still using DML statement, when we can achieve the same functionality ...
4
votes
0
answers
300
views
DML takes long time on custom object with no triggers/WF/PB on it
I've got a code, where on lead insert, I also insert 1 record of custom object Demand_Funnel__c. Demand_Funnel__c has no apex triggers, no WF rules, no Processes tied on it. If it's a first lead ...
3
votes
3
answers
6k
views
Partial insert of more than 10000 records
What happens when we use Database.insert to insert more than 10000 records with allOrNone set to False? Are only the first 10000 ones inserted?
1
vote
1
answer
462
views
DML is NOT Recommended in APEX Property Setter
I just got a strange recommendation from SalesForce support which was related to inability of APEX controller class to save value from VisualForce component to a custom setting.
The recommendation ...
1
vote
1
answer
209
views
UserAccountTeam - Test Class
I have a trigger that basically replicates adding the default team to the account team (it's doing more than just that but for ease of asking this question lets leave it at that case).
How would one ...
0
votes
1
answer
418
views
MIXED_DML_OPERATION on closing tasks upon user deactivation
I created a trigger that queries and deletes all related tasks once a user in deactivated.
and I am getting this frustrating error.
"MIXED_DML_OPERATION, DML operation on setup object is not ...
2
votes
1
answer
1k
views
Does Apex wait before moving onto next line
Gentlemen, simple question. Does Apex wait for the DML operation of inserting accounts to complete before moving onto the next line (SOQL statement)?
insert parentAcctList;
List<Id> acctIdList ...
0
votes
1
answer
68
views
How to create ongoing log of database actions on Custom Object records?
Context: A specific kind of sObject which is the detail in a master-detail relationship is getting mysteriously deleted across a number of different Master records.
I have been trying to narrow the ...
10
votes
2
answers
4k
views
How to call a standard controller action of a VF page from a VF component
I have a visual force page as follows which includes a component call Example one,
Component has a command button and I want to call the standard controller save action of VF page from the VF ...
2
votes
1
answer
1k
views
How could I test a BusinessHours class functionality with unit tests [duplicate]
I am trying to write a unit test for the following method,
public static DateTime addBusinessDays(DateTime startDate, Integer numberOfDays, String businessHoursName){
Integer ...