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 [dml]

Use this tag for questions about DML, the data manipulation language used in apex to perform operations as insert, update, delete, and restore data in the database.

Filter by
Sorted by
Tagged with
2 votes
0 answers
41 views

Salesforce code analyzer returns issue when using "as user" with dml

When I use delete with 'as user' and run sf code analyzer i get this problem: "PMDException: Error while parsing E:\testpro\force-app\main\default\classes\TestCl.cls Caused by: net.sourceforge....
Nazar's user avatar
  • 45
0 votes
0 answers
32 views

Rollback Mechanism in Salesforce

I'm seeking advice on performing an update operation in my database. Before saving the changes, I need to validate them through a third-party service using Mulesoft. If the response from the service ...
Amit Mathur's user avatar
0 votes
0 answers
49 views

How to Create/Insert a new record of the objects AccountAccountRelation and PartyRoleRelation?

these 2 objects AccountAccountRelation and PartyRoleRelation have been added to our project recently and I don't know why I cannot create a record of these objects. When I want to set the value of a ...
Gnopor's user avatar
  • 151
0 votes
1 answer
54 views

Turning off lead assignment rules in triggers not working?

I've a rest resource in apex which upserts leads based on the lead phone number but the problem is when lead owner is changed manually from UI and again it is updated from apex rest resource the ...
mine_username's user avatar
0 votes
1 answer
72 views

SObject type offer__c is not supported by this unit of work

In the project, we use fflib as the Apex enterprise framework. Executing this code: uow.registerDirty(offers); uow.commitWork(); I get this error: The object type offer__c is not supported by ...
EmmanuelP's user avatar
0 votes
0 answers
102 views

I can't find in salesforce, or using query editor in the developer console, custom object records that have been created in apex

I'm running apex code that creates related records for a custom object when a record is created or updated. The code runs without errors however I cannot see any of the related records in Salesforce ...
lhh13's user avatar
  • 41
2 votes
1 answer
363 views

DML operation Insert not allowed on Invoice

I am trying to insert a invoice record from apex code but getting the error "DML operation Insert not allowed on Invoice" . I am not sure is it some issue on permission level or salesforce ...
Sahil Gupta's user avatar
-2 votes
1 answer
584 views

Which is a better approach when updating records using batch class, to place it in execute or finish method?

Sorry but I am new to this and I just wander, do you think it is better to put all the millions of records inside the Map object which is process by the execute method, however the dml where the ...
Kato's user avatar
  • 1
9 votes
2 answers
704 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 vote
1 answer
67 views

I'm trying to bulkify the update of parent field based on child

I've written a trigger that is called when child record is inserted. I want the room(Parent) status to be updated to Occupied when the patient(Child) closure is set to false. Here's the code that I ...
Anirudh Navin's user avatar
0 votes
0 answers
23 views

Is there a work around for Creating multiple Parent and Child Records in a Single Statement Using Foreign Keys for the same SObject?

Im working on inserting multiple campaign records with a self-relationship. I was hoping to do this with one DML statement using the method described here: Link I know in the first paragraph it says ...
JEbert's user avatar
  • 11
0 votes
1 answer
138 views

Execute a batch with custom delay between each batch processing

I have a batch class which update the primary field on the quote object using batch size of 1. I need to do this in such a way that each batch is processed 30 seconds after the previous one(there ...
Tony Jude's user avatar
0 votes
1 answer
185 views

Do I need to Bulkify a DML inside a loop followed by end in Flows

I have a flow that only fires once per case record when an email-to-case comes in. It finds the email alias the case came through and assigned some values to the case record. I'm assessing a flow that ...
eHarazi's user avatar
  • 155
0 votes
0 answers
102 views

Check whether generic SObject is updateable

How do I check whether a generic SObject is updateable before DML operation. For standard and custom objects I know the general pattern is: Schema.sObjectType.Account.isUpdateable() However if I have ...
lhh13's user avatar
  • 41
0 votes
2 answers
372 views

Is DmlException is enough to catch all exceptions once wrapped for DML operation?

If we are using try catch only on DML operation part, where on catch block if only DmlException is used, then would it be enough to handle all possible errors occurs there or we also need to use ...
ItsVicky's user avatar
0 votes
2 answers
348 views

Is each chunk of a batch Apex class transaction gets shared among the trigger which runs before/after each DML of the batch?

If a batch apex is called with size say 200 (default size). And we have a DML operation (say update) in execute method of the batch. So the trigger which is set to run before/after update will share ...
ItsVicky's user avatar
1 vote
0 answers
174 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
2 answers
826 views

How do you pass a List of records to a batch apex class to be inserted?

I need to clone +10000 records. Yes,I'm aware of all of the limits and pitfalls associated with tying a trigger to a batch apex class. I'm accounting for it as only 1-2 people will be able to perform ...
Andrew Bloch's user avatar
1 vote
0 answers
45 views

Is there a good strategy to create complex nested SObjects in JavaScript for INSERT in Apex?

I'm implementing frequently Aura Components which must INSERT nested SObjects. As an example imagine you have this simplified data-model, references are lookups: ItemGroup__c Order__c OrderItem__c ...
Uwe Heim's user avatar
  • 28.4k
0 votes
1 answer
148 views

How to insert related record when DUPLICATES_DETECTED error is thrown from Salesforce Matching Rule?

I have a requirement to insert CampaignMembers whenever a duplicate Lead is identified. The duplicate check for all Leads of all Lead sources is handled via Standard Duplicate rule. This rule needs to ...
Apex Srinivas's user avatar
4 votes
1 answer
203 views

Is the User Mode approach to object and field security acceptable in a security review?

This Enforce User Mode for Database Operations looks by far the cleanest approach to implement the object and field-level security that is required to pass a Salesforce AppExchange Security Review. (...
Keith C's user avatar
  • 136k
-2 votes
1 answer
63 views

Pdf delete apex class [closed]

public class DocumentFileDeletionScheduler implements Schedulable { public void execute(SchedulableContext SC) { deleteOldFiles(); } public void deleteOldFiles() { ...
Csabikaaaa's user avatar
0 votes
0 answers
152 views

Get Update Count in Flow

I am using the Update Record element in a screen flow on the Specify conditions to identify records, and set fields individually setting. Is there a way to get a count of how many fields have been ...
Samantha Catania's user avatar
-1 votes
1 answer
33 views

update DML fails on contact......how to undo the update on Account and opportunity how do you implement that

Let's say in Apex you have multiple DML calls like update opportunity then you update Account and then you update contact, but it fails on contact so you want to undo the update on Account and ...
Jarvis's user avatar
  • 1
7 votes
3 answers
1k views

With USER_MODE - do we still need SOQL and DML libs?

As the Security model of Apex was leaky in the past, everybody who took - or as AppExchange Partners had to take - Security seriously was building or using libraries to enforce CRUD/FLS rules. The ...
Robert Sösemann's user avatar
3 votes
1 answer
745 views

Query: FLS Create issue while running checkmarx

I am running multiple classes and have some Query: FLS Create issues while running the checkmarx. I am really not knowing what they mean by this. I feel there is something simple but I cannot discern ...
Rahul Allada's user avatar
0 votes
1 answer
235 views

Is it safe to perform DMLs on related records in a `before delete` trigger?

I have two custom objects: Parent__c and Child__c. Parent__c has a field called ChildId__c which is a lookup on the Child__c object. When a Child__c record is deleted, I need to check if its Id ...
user369137's user avatar
0 votes
1 answer
303 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
464 views

Is List.isEmpty() necessary before a DML? [duplicate]

After working on many different code bases in Salesforce, I noticed that almost all developers check if a list is empty before doing a DML in order to avoid the unnecessary DML statement. Here's an ...
Harout Tatarian's user avatar
2 votes
1 answer
226 views

Cannot understand how the DML works in this code

I'm very new to apex and have just started learning. I was going through soql and came across this code that I'm not able to understand. Opportunity opp = [SELECT Id, Name FROM Opportunity WHERE Id = '...
PriyamSri28's user avatar
0 votes
2 answers
102 views

How to resolve too many SOQL after using Handler

I am using Trigger Handler for my Trigger. But still getting Too many SOQL on updateNoMaterialTool(); & Apex Class public class ProjectTriggerHandler { public Map<Id, Projects__c> ...
apz's user avatar
  • 5
0 votes
0 answers
298 views

Why am I not seeing records that are ostensibly inserted?

We're creating sample data when we spin up a scratch org, and we have just added a new join table between two existing tables, but the records don't seem to be actually inserting, although the code I'...
Chuck's user avatar
  • 967
0 votes
1 answer
54 views

APex code + DML operation works in dev console but doesn't work in scratch org

Was wondering if anyone has come across a similar issue: I'm trying to run some apex code to insert some records. The code doesn't seem to do anything when it's running in my scratch org but ...
srrc's user avatar
  • 5
1 vote
1 answer
227 views

Apex: I'm shoving all the DML into a queued job, but still get "Uncommited work pending"

So, I've heard that you cannot do any Callouts after a DML operation in Apex. So, I've designed my app this way (some pseudo-code follows): String url; List<Object> chunk; for (Integer page=1; ...
pilat's user avatar
  • 113
-2 votes
1 answer
206 views

Mass Contact Merge in Apex

I am trying to implement Mass merge of contacts in apex, Like uploading a CSV of multiple records which has would have details like retainable ID , duplicate contact Id etc., now I need to traverse ...
Kishore's user avatar
2 votes
2 answers
255 views

How can I dynamically upsert data in object

I want to upsert data in SF based on the selected columns by the user. I make HTTP callout to an external service and it returns the data. Then, I want to iterate over the each returned row and create ...
Stojchesky's user avatar
0 votes
1 answer
119 views

What are possible side effects of having fields on User object which should be frequently updated?

For integration purposes I would like to store a few custom fields on User object which should be updated 10-30 times per day. Is it considered a good practice to have such fields on User object? Are ...
Taras Shevchuk's user avatar
10 votes
2 answers
6k views

Any reason NOT to use FOR UPDATE?

I'm intrigued by the record locking issues that Apex seems to allow so easily, and I've begun using FOR UPDATE where I can to mitigate them, but it seems so infrequently recommended in documentation. ...
number41's user avatar
  • 960
1 vote
1 answer
957 views

Send email and update field via Apex

I have apex class which is sending email and it works perfect, but together with email I want to change Case status and update a custom field. Inside for loop it works, but I don't want to exceed ...
NewToApex's user avatar
1 vote
0 answers
289 views

assigning role to user in apex leading to an error

I am trying to assign role to a user which i created and thats when I am getting this error : First exception on row 0 with id 0051k000008ykexAAA; first error: INVALID_CROSS_REFERENCE_KEY, invalid ...
Donal Shijan's user avatar
0 votes
1 answer
288 views

How to insert a record and input values from the master/parent information

I have a custom object named "Property Booking" where if the status changed to approved I have to create a record for my "Quotation" custom object. The tricky part here for me is I ...
Kejer's user avatar
  • 31
1 vote
0 answers
271 views

Best Data Layer structure in APEX when trying to follow proper SOC?

Backstory: I am currently working in a org that has not implemented proper SOC when it comes to our codebase. WE have some Trigger logic in the trigger files and most of our business logic intertwined ...
hmmm's user avatar
  • 11
0 votes
2 answers
722 views

Cleaner way to filter specific object ids from List <String>?

I am trying to update one of the related objects once the Account merge is completed. Database.MergeResult results = Database.merge(masterAcct, duplicateAcct, false); getUpdatedRelatedIds() method ...
SunnyG's user avatar
  • 421
0 votes
0 answers
190 views

How can I merge two Account custom objects into one without saving it to the database?

I have two saved account objects with the same Name and Email. Use case: I need to display these two objects' data to a user. The user selects one master object System merges whole non-master object ...
Alexander Belenov's user avatar
2 votes
2 answers
1k views

Is it possible to only update one field?

Is it possible to only update one field? List<Account> accountsFromSF = [SELECT Email_3__c from Account LIMIT 50]; for (Account acc : accountsFromSF){ acc.Email_3__c = '[email protected]'; } ...
LatDu's user avatar
  • 59
0 votes
1 answer
91 views

DML, SOQL and DML Sequence

Here is my scenario. Transaction 1: DML to update the Status field from Open to Closed on ABC record. Transaction 2: SOQL is performed to retrieve the ABC record before the above DML and updates the ...
Ram's user avatar
  • 5
0 votes
1 answer
394 views

Trigger not updating records - DML not being called(?)

I created a Trigger on Contact to update the associated Account each time a Contact is added or edited; the Trigger checks that each Contact in the Account has a valid credit card associated with it, ...
ElTttt's user avatar
  • 21
0 votes
2 answers
26 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 '...
parkerbbrown's user avatar
0 votes
1 answer
695 views

Save Parent - Child Hierarchy for same SObject in a single DML

I want to save the lookup relationship for same object in a single DML statement, so basically I want to do something similar like this but for same Sobject, I have found one article here but this is ...
Akash Jain's user avatar
0 votes
0 answers
443 views

CPU Time Limit Exceeded Trying to Email 2000 Contacts

I have a junction object called AccountContactRelation which is linked to both the Contact and Account objects. I am trying to sort through the accounts, and for each one, add all the related ...
Austin Kelly's user avatar

1
2 3 4 5
11