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.

learn more… | top users | synonyms

8
votes
1answer
76 views

What is DML? How different is it from SOQL Actions?

This question is designated as a community wiki, please add your inputs, guides (please try to ignore oustside links, and bring the important skimmed data in here. What is DML? What is Dynamic-DML? ...
1
vote
1answer
55 views

DML inside apex controller

I have a generic question in my mind. Suppose that we have an apex controller that is doing DML operations on a custom object. Now my questions are Does context user's profile affect DML operations? ...
1
vote
1answer
34 views

Calling a dml statement in a constructor of a controller

I understand that we cannot have dml statement in controllers constructor. But in my case, i have a query string which is used to run our pages. So my code reads the querystring variable in the ...
1
vote
1answer
59 views

Question on Salesforce rollbacks on dml operation

I encountered a weird issue which i wanted to get feedback from you guys. Currently we have 2 sandboxes where we are doing development currently. We are experiencing an odd behavior where none of the ...
1
vote
1answer
90 views

Issues with Database.upsert statement

I am using a Database.upsert statement to upsert a custom object record in apex. In my method, i do an upsert and i am printing the id and the errors. I am getting an id on the result and also the ...
3
votes
2answers
55 views

Building VF Apps for Scale - Avoiding Locking Rows

Cut to the chase: What causes UNABLE_TO_LOCK_ROW errors and what are best practices for avoiding them? We built a great app that works solidly in development and testing. Today we launched to a ...
2
votes
4answers
181 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 ...
4
votes
1answer
34 views

Does opt_allOrNone guard against partial lead conversions?

There is a brief note at http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_convertLead.htm about opt_allOrNone preventing partial success of the convertLead DML operation: The ...
1
vote
3answers
66 views

Optimized way to update parent object

What is the most optimized way to update every parent object inside a list? For example: List<Asset> aList = [ SELECT Account.Name FROM Asset WHERE ...
3
votes
2answers
91 views

Can we have a DML not roll back when i use an adderror method?

We have a scenario where in the before insert trigger of object Asset, which looks for a duplicate and if a duplicate is found a record is inserted in the junction table and after the dml is complete, ...
4
votes
2answers
103 views

Rolling back DML operation in Apex method

What is the best way to rollback some changes to the database inside an Apex method? For example, in an Apex method, I insert multiple records (Opportunity / Quote / QuoteLineItems). When I execute ...
6
votes
4answers
81 views

Alternatives to using page action for user preferences

Sometimes you have to load user preferences stored in a Hierarchy custom setting when a Visualforce page loads. If the preferences exist, then retrieve them, otherwise create them and insert them. ...
1
vote
1answer
27 views

Chatter for exceptions

I have a page that is doing a lot of heavy-lifting server-side and then showing up as a page-within-a-page on a custom object layout. When something goes wrong (usually finding no available products) ...
4
votes
3answers
106 views

Rollback whole Batch on error

I am using an APEX batch to process and insert large amounts of data. Essentially I would like it to process every row to catch any errors with the data and then rollback the entire batch if a single ...
4
votes
1answer
152 views

REQUIRED_FIELD_MISSING, Required fields are missing: [Name]: [Name]

when i trying to insert opportunity in my testclass i am getting an error Test_opportunityTrigger.Test_opportunityTrigger: line 24, column 1 22:28:17.312 ...
6
votes
1answer
103 views

DML not allowed in page action

So I understand DML Operations aren't allowed in getters/setters,constructors but it was my understanding that they were allowed in methods that were invoked by page-actions like so: page: ...
3
votes
1answer
62 views

MRU List when Inserting/Update record from APEX trigger

Can we set an option when inserting record via APEX Trigger that the record "does not" show up in Salesforce MRU (Recent items list) ?
0
votes
0answers
168 views

Setting new user passwords in Apex

I have a method that creates a new user and sets a custom password, everything works fine to the point where I try to log in with the new user and get an error that the login details are incorrect. ...
1
vote
2answers
120 views

Deploying an Apex Class for a Custom Button - Too Many DML Statements Error

I am attempting to deploy an Apex Class from a sandbox environment to a production environment of Salesforce and I am having issues with the deployment. I am very new at this, so please forgive my ...
0
votes
1answer
56 views

Not Updating values when their is a rendering

I have a Vf page with rendering say <apex:outputpanel rendered="{!payment.paytype__c==true}"> //My code goes here </apex:outputpanel> In my class public ...
1
vote
1answer
68 views

Connection was cancelled here, Interrupting long running request

Sometimes an Apex request gets interrupted/terminated by Force.com. The underlying Apex request contains numerous DML statments (insert into around 13 custom objects) all of which marked at a ...
3
votes
2answers
165 views

Id assignment when creating sObjects in code

I'd like to get straight exactly what is happening when I create an sObject in Force.com code but can't find any information on the specifics. The Id is null until after the DML insert statement. ...
6
votes
2answers
361 views

Creating a user with DML

I have the following Apex code: User mike = new User(); mike.Username= 'mike.white@company.com'; mike.Email = 'mike.white@company.com'; mike.Lastname = 'mike'; mike.Firstname = 'white'; mike.Alias = ...
5
votes
1answer
113 views

Submit records for approval in bulk without hitting DML Statement limit

I've got code to create and submit for approval a custom object. I'm running into the DML statement limit. As far as I can see each record I submit for approval takes up a DML statement, but there's ...
4
votes
2answers
174 views

MIXED_DML_OPERATION, Not Allowed: Original Object CronJobDetail

I'm trying to get around the MIXED_DML_OPERATION. I touch some custom sObjects, custom settings, and than schedule a CronJob via System.schedule The API Version of these classes is v19, and it's my ...
7
votes
1answer
305 views

Is there a way to make the insert not fail if one record fails?

I am inserting multiple records using Apex DML; e.g. List<Account> accounts = new List<Account>(); // Populate the accounts list insert accounts; If there is any kind of error ...
2
votes
1answer
298 views

Compile Error: Comparison arguments must be compatible types

Can someone tell me why this error would show up in this canned code I am using from SF's dev site? Enterprise Release 12 of SF.... Error: Compile Error: Comparison arguments must be compatible ...
6
votes
3answers
313 views

Can you perform DML operations from visualforce email templates?

Visualforce email templates allow you to include visualforce components with allowDML="true" but there doesn't appear to be any way to actually use DML. From the docs: You can't use data ...