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
-1
votes
1answer
22 views

Is there an hourly API/DML limit? Or per-user limit?

I know there's the daily/monthly limits, which we aren't exceeding. However, we are seeing an issue where one of our Integration Users is seeing their API calls stalling out, but at the top of the ...
1
vote
2answers
21 views

How to avoid Multiple DMLs on a single transaction while populating Rollup fields in Lookup relationship using triggers

I have a trigger on child object.From the handler I am calling the helper method multiple times to update 4 rollup fields on parent record. I have a working logic but I am concerned about repeatedly ...
0
votes
1answer
72 views

How can I find problematic records in a dml action?

Let's assume I have a list of 100 new records that I want to insert, 10 of these records are missing information which will result in DML exception. Is there a way for me to create a list and include ...
0
votes
1answer
31 views

FLS Create Security Risk still appears even though object is checked if it is creatable

So I have this code: obj.field1__c = 'placeholder'; if(MyCustomObject__c.sObjectType.getDescribe().isCreateable()){ insert obj; } When I receive the (Checkmarx Source Scanner report), I still get ...
0
votes
1answer
745 views

Deleting all public groups from Org

We have an utility which imports all data from one org to another, this results in creating public groups every time import operation is carried out. Is there any way we can perform delete operation ...
0
votes
1answer
32 views

Skip Sobject that has an error during DML operation

I have a list of Sobject which I'm trying to update, but I want to skip those Sobjects that throw an error or more precisely those that have Sobject.addError('') during the trigger call. i.e if I ...
0
votes
1answer
27 views

Upsert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION Invalid vote type '5-star(db=6,api=5)'

//This method is used to upsert an vote for article @AuraEnabled public static String upsertVote(Id voteId, String kbId, String val){ System.debug('voteId::'+voteId); System.debug('kbId::'+...
0
votes
1answer
39 views

Error: Opportunity must have a primary quote in order to create an order.: [] - SBQQ CPQ Test class

I am very new to CPQ, and I am given a test class to write directly. When I try creating order in my test class, I am getting this error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Opportunity must have a ...
2
votes
1answer
37 views

Lookup fields have id values even though parent object has been deleted - tips on fixing?

In a sandbox org whenever I try to perform any DML on a Product2 object I'm getting the generic invalid cross reference key error even if I'm only supplying the id field. 16:59:05.12 (140169065)|...
15
votes
6answers
19k views

Triggering a DML Exception for Test Coverage

I have an Apex Class, where 55% of the code is inside a catch, requiring a DML exception to be executed. Since the DML update request is using data from an SOQL request inside this class, I have no ...
0
votes
1answer
591 views

Org Data Update just after the sandbox refresh in FullCopy Sandbox

Our requirement is to update customer's email ID and Phone# to an invalid value in FullCopy sandbox during the sandbox refresh. Using PostSandbox refresh apex class we are updating the User email and ...
0
votes
1answer
25 views

Update parent field

I have an order which I am creating from another order and I have lookup on order - ParentOrder__c. When I create the child order, I would like to update field Prolongated__c(which is checkbox) on ...
13
votes
2answers
13k views

Updating multi currency rates from Apex

I just looked in the Salesforce.com documentation for a way to update currency rates using Apex, but I have a vague feeling that this is not possible using standard features. I noticed that a couple ...
0
votes
1answer
38 views

Difference between Upsert and Update database methods

Good morning. Database.update (fields , allOrNothing) Database.upsert (fields, externalId, allOrNothing) I need help to understand why the second parameter "externalId" is not necessary on ...
0
votes
1answer
524 views

Mixed DML Operation - creating Resource via Flow

I have a Flow where I create a User and a resource, related to that user, the object resource is managed by Field Service Lightning Package from Salesforce. The Flow itself seems to work fine, except ...
4
votes
2answers
2k views

Why is my locked record editable?

Why is my record locked? I created a record, but, when shown in detail view, it has the 'locked' icon, and appears to be locked at first view, but- Why can I edit the locked record (Even as a standard ...
3
votes
1answer
51 views

Security.stripInaccessible not returning Id of new records (running as sys admin)

I am trying to update my existing code to use the fancy new Security.stripInaccessible method. My current code to create records is very generic and so I have a method header something like the ...
0
votes
0answers
46 views

"You have uncommited work pending" when there's no obvious DML?

I have a RestResource which is running some callouts, as well as running some DML (after the callouts). I'm recieving this error: You have uncommited work pending. Please commit or rollback before ...
5
votes
1answer
1k views

How to save large files in Salesforce with synchronous Apex?

I've created a Visualforce page that allows users to drag and drop files and have them uploaded to Salesforce and then displayed in a list immediately. To do so, my VF page sends the file in chunks ...
0
votes
1answer
1k views

Why trigger.old cannot be operated on DML statements? [duplicate]

I am new to salesforce so correct me wherever I am wrong. I believe DML statements can work on already saved records so it makes sense that trigger.new cannot be operated with DML statements but ...
0
votes
1answer
32 views

Upserting a list of SObjects is creating duplicates

I have an external Id field called Unique_Identifier__c which is a concatenation of two fields on this Custom SObject Recipient. This field is created/populated at before insert. I want to allow the ...
-3
votes
1answer
82 views

inserting records using Apex Web service [closed]

The user has access to apex class.I am trying to insert accounts using apex web service. and making a callout using apex. This is my code.but it seems that the apex web service is not receiving the ...
1
vote
1answer
1k views

Possible Workaround to perform DML when cacheable is true

According to documentation, it is recommended to make wired apex calls from LWC cached, by adding the following annotation to the controller's method: @AuraEnabled(cacheable=true) However, adding ...
0
votes
1answer
36 views

Can we delete list which contains different SObjects with one DML statement?

I have List which can contains Accounts and Contacts ; Can we delete the list using just ? List<SObject> testList; delete testList; Can we delete list which contains different SObjects with ...
2
votes
1answer
140 views

Why am I getting a "Too many DML statements: 1" in a non-cacheable Apex method?

I have this Apex method in a controller class: @AuraEnabled public static void deleteTagAssignment(Id loanId, String name) { TagAssignment__c assignment = [ SELECT Id FROM ...
2
votes
1answer
152 views

Flow component : Delete Records

I have a Screen Flow. There is one Screen Element containing a Lightning Web Component which is based on the standard lightning-datatable component, which allows the user to edit a set of records. ...
2
votes
1answer
184 views

Can you delete AccountHistory data?

Does anyone know if it's possible to delete AccountHistory data? Bonus points: Is there an easy way to find the total number of AccountHistory records in an org?
0
votes
1answer
28 views

Navigation Link Set: Too many retries of batch save in the presence of Apex triggers with failures: when triggers are present partial save requires

I am trying and deploy a Navigation Link Set But, I am getting error message: Too many retries of batch save in the presence of Apex triggers with failures: when triggers are present partial save ...
-2
votes
1answer
17 views

Update sibling records from the same object fails

I have a custom object called 'myObject__c'. This object has a lookup with Account. Now I want to get the values of an existing record (e.g. recordA) and update another record (e.g. recordB). this is ...
-3
votes
1answer
43 views

DML and callout in same future [closed]

I need to do a call-out to get a token on the trigger. In this case, you need to save this token through the DML operation. Callout and trigger cannot be performed in one operation. How can I make a ...
-3
votes
1answer
30 views

Integration of salesforce for file uploads and insert [closed]

Is there any way to upload, insert files from any excel sheets(google sheets, MS,...) into salesforce records?
0
votes
0answers
35 views

Apex for Admin Trailhead: Code Not Working

I'm working through the Trailhead and have triple checked my work, watched the video that goes along with the unit, and have researched the problem as much as I know how. The problem is linked here:...
0
votes
1answer
64 views

Update record in rest callout

Hi I try to update an existing record using REST callout. String uri = 'https://test--dev.my.salesforce.com/services/data/v25.0/sobjects/Account/' + ACCId; HttpRequest reqUpd = new HttpRequest(); ...
0
votes
2answers
49 views

Hi, I would like to know if anyone can help me to write a method to have better this code and if this have errors can you tell me that error

public class MyPageController { public void recalculateTotals() { List<MyCustomObject__c> myCustomObjects = [SELECT Id, Totals__c, Recalculate__c, Value1__c FROM MyCustomObject__c]; ...
24
votes
2answers
500 views

Email value is saved without parentheses (label) when using DML

When an email contains a label enclosed in parentheses, the value can be saved as typed in via SF UI. (Note: the email value "as is" is only seen when in Edit mode.) However, when the record is saved ...
1
vote
1answer
128 views

How to compare the Database.Error getStatusCode() value against a string (In a clean way)

I have the following code which uses string concatenation to check the err.getStatusCode() if (err.getStatusCode()+'' != 'ENTITY_IS_DELETED'). My question is, if there's a cleaner/better way to do ...
0
votes
1answer
154 views

Logging Apex exceptions through Event Bus while still rolling back the entire transaction?

I'm working on implementing a robust error logging framework for our org using Platform Events to ensure that we always capture errors in our code even if the transaction is rolled back. If I use ...
-2
votes
2answers
573 views

Apex error : You have uncommitted work pending. Please commit or rollback before calling out [duplicate]

Apex error : You have uncommitted work pending. Please commit or rollback before calling out. I get the above error when I try to make two http callout one after the other and store the result in ...
0
votes
0answers
38 views

insufficient access on cross reference Id during insert of child detail record in after insert of parent record

public static void createQuoteLineItem(sales_Toolkit__c[] newQuote, OpportunityLineItem[] oppLine { List<Conversion__c> newQline = new list<Conversion__c>(); Id parentQuoteId; //...
0
votes
0answers
168 views

Duplicate Record Being Created on Update DML

I seem to have tracked down where duplicate records are being created, and I believe it is in this updateRecordGuest class. This class is wired in a LWC and we are passing in the record Id for the ...
1
vote
1answer
68 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 ...
0
votes
1answer
530 views

System.TypeException: DML operation INSERT not allowed on QueueSobject

I am trying to insert a QueueSObject in test class but getting the error System.TypeException: DML operation INSERT not allowed on QueueSobject This code was working before but started giving error ...
1
vote
0answers
65 views

RowCase is manual but still can't delete account share

This code here fails: List<AccountShare> existingShares = [SELECT Id FROM AccountShare WHERE RowCause = 'Manual' ...
0
votes
1answer
36 views

Security with Mixed SObjects

I am attempting to find best practices around mixed SObject security. When I am using DML statements I validate either through "with SECURITY_ENFORCED" or through {SObject}.SObjectType....
3
votes
1answer
252 views

Uncommitted Work Pending - Working around DML then WebService

I am working with Salesforce Connect and I am storing my token and expiration times in an encrypted custom setting. My connection is through the client credentials Oauth 2 flow. When a user queries ...
3
votes
1answer
157 views

Updating an instance of Custom Setting via DML

So I implemented a callout to an external service where first we should validate that our token wasn't expired. So I implemented a refresh token method, that updated our custom setting where we stored ...
0
votes
1answer
2k views

Edit properties of a Visualforce Email Template in apex so the email sent through Messaging.sendEmail() will have the most recent data in it

I have a visualforce email template that displays the list of Opportunity records that are populated using a visualforce component. I'm using this email template in a schedulable class. The HTML ...
1
vote
0answers
84 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
0answers
107 views

Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, unexpected metadata: []

I'm creating a time based flow in which I have to delete Opportunity Team Member Record after 2 hours of createdDate when it's custom checkBox field is 'true'. But when I'm inserting an Opportunity ...
0
votes
0answers
43 views

Way to partially filter inserted records in before trigger

Let's say we have bulk DML that is gonna insert a couple of records. In before trigger we want to check all new records and insert only correct (matched) ones. Should we use another DML inside the ...

1
2 3 4 5
10