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

DML Not Allowed

I am getting an error when trying to kick off an approval flow programatically. I have seen others run into a similar issue with the DML not allowed. Why is DML not allowed in Constructor? I tried ...
1
vote
1answer
703 views

Error creating CPQ - SBQQ__QuoteLine__c Object

I am trying to test a controller that I have written which queries SBQQ__QuoteLine__c objects. I am running into an error which is preventing me from inserting the object during the @TestSetup method. ...
1
vote
1answer
116 views

move all child records from one account to another efficiently

I did a bit of searching and didn't come up with anything so apologies if this is a duplicate, but - Situation: I am looking for a way to migrate all related object records from one (bad) account ...
0
votes
1answer
37 views

Convert Objecttype for DML update

Trying to update a child object from a parent object using the Objecttype returned form a getReferenceTo() but getting errors as Method does not exist or incorrect signature: How can I convert the ...
1
vote
2answers
266 views

Does an update called in an @future method count as being in the same transaction as the method that called it?

I am on occasion seeing a "You have uncommitted work pending. Please commit or rollback before calling out" error during a sequence of callouts that are part of the same transaction. So basically the ...
0
votes
1answer
266 views

DML requires SObject or SObject list type: String (line 31)

For the below code I got this error on line 31 i.e upsert z; global class updatezone implements Database.Batchable < sObject > , Database.stateful { string query; string z; //Start ...
0
votes
1answer
172 views

Order of execution and multiple DML in a single transaction

I have a trigger that has multiple DML operations in a single transaction. I also only want the transaction to run once. With the order of execution I need to put some sort of "first run" logic on it....
1
vote
1answer
89 views

Cross-Object Formula Fields and Performance

I have been unable to find official documentation about this. But I wonder, is there a documented "upper bound" count at which platform performance degradation occurs due to a proliferation of cross-...
0
votes
2answers
139 views

Issue inserting a ContactShare object with Database.SaveResult

I need to insert a new ContactShare object in apex. Here is a sample of the code I have : Map<String, Id> mapUserRole = new Map<String, Id>(); for(UserRole ur : lRoles){ ...
0
votes
1answer
82 views

Schedule Iteration of Webservice Callouts

I have an endpoint I am getting updates from, but the only arguments the end point takes is two date parameters. To keep the heap size down, I am limited to about a date range of three months. I am ...
0
votes
2answers
513 views

Delete related records in trigger before delete

I have installed NPSP in my organisation. I also created a custom object named as "Opportunity Group(OppGroup__c)" that will group my opportunities. What I want is that during deletion of an "...
1
vote
1answer
153 views

How do I mass delete Territory2 records in Apex?

I have a list of Territory2 records. All of them are from the deepest level of my territory hierarchy. When I attempt to save some apex to Salesforce that would delete this list of records, I'm ...
0
votes
1answer
364 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
62 views

New Record creation on custom object - An internal server error has occurred - Error ID: 1803087759-275934 (-1232085095)

I am trying to create a new record on a custom object which has record types and save the record. I get the below error An internal server error has occurred An error has occurred while ...
0
votes
1answer
38 views

Testing future methods: data scope

I'm trying to test my @future method, in which I'm performing Custom Object update, but when I'm asserting values, updated object field equals null. Could it be a problem with method scope? I'm adding ...
1
vote
1answer
369 views

In test class Topic and Topic assignment creation isnot working

Iam creating dummy records for Topic and its assignment.Topic is creating successfully Topic assignment shows error Below error: Failed to assign topic to null. Please ensure you have permissions ...
3
votes
1answer
83 views

@ReadOnly won't work when using Aggregate SOQL

I've created this function with @ReadOnly in a Visualforce that is Working fine (1.000.000 records limit): @readonly webservice static List<BI_BR_Atendimento_Comercial_e_Carteira__c> ...
0
votes
1answer
364 views

System.ListException: Before Insert or Upsert list must not have two identically equal elements for my DML operation [duplicate]

I have below code where I try to insert an SObject and getting an error as mentioned in subject. I have tried to fetch newly inserted records of say Object1, and putting them in Object2 lookup field ...
2
votes
2answers
206 views

System.calloutException: You have uncommitted work pending. CallOut+Asynchrnous DML + Callout

I went through some questions here like System.CalloutException: You have uncommitted work pending which provide answer where the callout can be split into asynchronous way. Based on the information ...
0
votes
1answer
214 views

Work Order Line Item not being inserted in test class

I have a piece of code in my apex class which queries a work order with the corresponding Case ID. I have written the corresponding test method for this class, as follows: Case c = new Case(); ...
0
votes
1answer
577 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 ...
4
votes
1answer
64 views

In a Salesforce Number field, how much performance impact does its length have?

Does a 2,2 field perform noticeably better than a 16,2 if the same value (e.g. 24.45) is stored in the context of Apex DML Formulas whatever I forgot, please add To clarify: This question ...
-2
votes
1answer
258 views

What is the execution time spent in the database for an DML or SOQL or SOSL?

Is it possible to find the execution time for a DML or SOQL or SOSL? What are the factors on which the execution time of these queries depend?
-1
votes
1answer
345 views

Test REQUIRED_FIELD_MISSING even though field is set?

@isTest private class Test_ordinefermo { @isTest static void test_newAttachment(){ test.startTest(); Opportunity op= new Opportunity(); op.Name= 'abc'; ...
7
votes
1answer
65 views

From inside a Salesforce packaging org, how do you query the list of created versions for a managed package?

I have, a Salesforce packaging org, it contains a managed package with a namespace. I need to be able to query the list of created versions for that managed package. I am aware that a user can go ...
1
vote
2answers
670 views

Why does setting DMLOptions in the before event not work?

I need to trigger case assignment rules on update from a lightning page. I referred to this link to do that via trigger. After a little modification, I called the below method in before update event, ...
0
votes
0answers
21 views

Updating a value in the list to be updated before and after the dml operation

Im trying to update child record in parent after trigger, where i need to update this child's boolean (MA_Campaign_Qty_Boolean__c) as part of restricting some validation in child's trigger for this ...
0
votes
1answer
45 views

Query returning value from database and not test class

I'm having trouble with my code coverage and have a couple of hypothesis why this could be. My class: public class Tareas_Ordenador { public static void Ordenar(){ User Usuario = [Select Id ...
0
votes
1answer
170 views

UserTeamMember Apex DML

I'm trying to insert some UserTeamMembers in an Apex test class but i'm getting the "DML operation Insert not allowed on UserTeamMember" error. Looking at the documentation (https://developer....
6
votes
0answers
124 views

How many child records can a parent cascade delete (documented limit)?

I have a CustomObject__c which has childrens 2 level deep. Together a single parent object can have many 10.000 child records. Would it work to auto-delete the thousands ob child records just using a ...
1
vote
0answers
26 views

Updating event restores event relations I just deleted?

I have need to programmatically delete an event relation for an event, then add a new one, then do some updating of the event information, then update the event. I have ran into some roadblocks: If ...
0
votes
1answer
36 views

Allow the insert of Custom Records even if some of them fail as duplicates

I want to ignore a bunch of records (Custom settings in fact) and want the transaction to ignore Duplicate errors. All other errors should make the insert fail. If a duplicate exists simply skip the ...
-3
votes
1answer
771 views

Unable to insert opportunitylineItem in apex code?

public class NewMedicineBillVF1_Ctrl{ public Boolean displayPopup {get;set;} public List<ProWrapper> pwrlist{get;set;} private List<OpportunityLineItem> olilist; public Product2 pro{get;...
1
vote
1answer
77 views

Apex Approval Process Locks on DML Statements

I have a custom button on a record which is designed to update the record's status. There is a separate process within a different class, which is locking the record. I need my pageRef to unlock the ...
0
votes
2answers
660 views

How exactly do you update/insert documents in apex?

I have a very simple update here: Document emailDoc = emailLogoDoc[0]; emailDoc.Body = newLogoData.emailLogo; emailDoc.Url = Url.getSalesforceBaseUrl().getProtocol() + '://'+System.Url....
2
votes
1answer
115 views

DML external Id relationship throwing Internal Salesforce.com error in sandboxes with Winter 18 release

I'm facing an issue with one of my batch process when trying to relate records through an external Id. I have a csv file with info about the record to upsert, and a external id of the account that i ...
2
votes
1answer
61 views

AppExchange ISV Security Review CRUD/FLS Puzzler

Who knows the answer to this puzzler? Q: If a Visualforce Page is using a standard controller with a custom controller extension and the controller extension is declared "with sharing", do we need ...
0
votes
1answer
742 views

Check for empty list not working

I have this method where I want to call another method from based on a check if a List is not empty. I get the error: System.QueryException: List has no rows for assignment to SObject Error is in ...
2
votes
1answer
511 views

How to merge multiple records outside of a for loop? [duplicate]

I have a list of master accounts that each map to a single duplicate account. I want to merge each master with its corresponding duplicate using the merge DML operation. I'm currently doing this in a ...
3
votes
2answers
64 views

Can the exact type of an Apex list be checked to choose between upsert and insert/update?

I have a utility method that that works on lists of SObjects that are normally of one type: private void oneType() { Contact[] contacts = new Contact[] {}; contacts.add(new Contact(...)); ...
0
votes
1answer
43 views

Test class no inserting object

I have a test class that seems not to be inserting some setup objects I need for the test. My test class is as follows: @isTest(seealldata=false) private class Alertas_The_Influence_isTest{ public ...
2
votes
2answers
343 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 ...
0
votes
1answer
167 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 ...
0
votes
1answer
116 views

How can I find out what fields made my upsert fail?

I'm trying to upsert some records. I use Database.upsert. If the failure is related to a duplicate value (external ids that have to be unique) I need to know what fields are duplicate and clear (...
1
vote
1answer
25 views

Compile Error on batch class to fetch fields from saveresult

I have below code to fetch field values from records of Database.Saveresult. I am getting error as below. Error Expression of type Database.SaveResult has no member named Territory_Name__c Code ...
0
votes
1answer
298 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
2answers
992 views

Error in apex class : System.LimitException: Too many DML rows: 10001

While I am trying to perform an upsert, I am getting this error : System.LimitException: Too many DML rows: 10001 at the line where the upsert statement is written. Code snippet : public class ...
3
votes
0answers
85 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 ...
0
votes
1answer
35 views

Is CorsWhitelistEntry insertable/updatable through APEX/DML?

CorsWhitelistEntry cors = new CorsWhitelistEntry(); cors.UrlPattern = 'sdfsdf.com'; insert cors; Wherever I try the above (or any other DML operation), I get an error message: DML operation ... ...
0
votes
1answer
104 views

Multiple DML operations in on update trigger

In an update trigger on parent object I need to do insert/update/delete on child object depending on criteria in parent object. insert and update works as required. but when delete error thrown as ...