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

0
votes
1answer
16 views

Variable does not exist error on custom field name

I have an object XYZ having custom fields AssigneeId and PermissionSetID. Now I have a list insAssignmentList of the object XYZ. I try to add values to the list by below line inside a for loop and ...
0
votes
1answer
39 views

Update External Id in Before Trigger Not Working

I'm creating some prep apex to run when we receive an account .csv that we've automated daily to push into salesforce. The idea is that some of these fields we want them to update our primary fields ...
2
votes
1answer
31 views

Test coverage for a user trigger: How to prevent “DML not allowed on User” in test-class?

I want to deploy a trigger on user. Therefore I need > 1% coverage on the trigger. To invoke the trigger in my test class, I've tried this: @isTest public class elfTriggerFrameworkTest { public ...
1
vote
1answer
29 views

All-or-none before insert - is it possible to maintain record changes between trigger attempts?

According to Bulk DML Exception Handling : Apex triggers are fired for the first save attempt, and if errors are encountered for some records and subsequent attempts are made to save the subset of ...
1
vote
1answer
18 views

Prevent record from being inserted in before trigger without adding errors

Is it possible to prevent single record from being inserted in before trigger without addError()? I'd like to be able to insert just a subset of inserted records without throwing any errors.
1
vote
1answer
26 views

Removing a cell in a row in Apex

Im jut wondering what is the best way to remove a single cell/column (I dont know what the word in Apex is) from a row. So I have a bunch of reports and I want to remove the deal from them. I was ...
1
vote
2answers
40 views

Getting Issues while creating User

I am trying to create an User but I am getting error as follows: 18:46:26:307 FATAL_ERROR System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, portal ...
1
vote
2answers
56 views

Creating records using Remote objects

Can we create multiple records at a time using remote object create() call? If yes what is the syntax? I tried passing a list of objects to create call but it didn't work.
5
votes
1answer
83 views

DML “10 chunks exception” and weird pattern

I am aware of System.TypeException: Cannot have more than 10 chunks in a single operation exception and it seems to be a known bug. I am also aware, that there are some other ways one can encounter ...
0
votes
3answers
39 views

Does list element get removed after deletion of that record from database?

Updated my question: Scenario:I am making certain changes in an opportunity record and clicking save. This causes trigger to execute and this trigger is executed recursively 3-4 times. Now say I have ...
2
votes
1answer
38 views

Get the inserted record id in a upsert call?

I am using below code to get the id of all record id whether it is update of inserted. upsert custmerList Name; for(customer__c afterUpsert : custmerList){ system.debug('*** Id = ' + afterUpsert....
0
votes
1answer
24 views

Unit testing: Assigning a Custom Obj Auto-Number to String Variable?

I have been trying to successfully compile a Test Class for triggers that auto-insert a DML_Log__c upon a specific sObject type being deleted, and an error keeps getting thrown: Expression cannot ...
1
vote
1answer
62 views

System logging: How to get.SobJRecordType() Record Type Name

Related to my latest flurry of questions, I am trying to write the Record Type Name as a String data type into a text DML Log custom object field. You will likely be able to tell by my code that I ...
1
vote
1answer
18 views

Why is get.sobject('Id') method appending a 3-char string? [duplicate]

I am creating a custom DML Log in our Salesforce sandbox, and I created a Class & method that fires based on an Apex Trigger Here's the class: public class Util { public static void ...
3
votes
1answer
108 views

DML update in @future callout not updating sObject

I've got a Apex class that takes the data from an Account object and uses it to create an account in my company's database by hitting an API. The API accepts JSON then inserts all the appropriate ...
0
votes
1answer
64 views

Insert Operation using Map Instead of List

How can I implement insert operation using map collection instead of list? I've created a conference scheduling app wherein upon selecting a certain student from a picklist, a table containing ...
0
votes
3answers
87 views

DML Statement in ‘after trigger’ and not in ‘before trigger’?

Why we need to use DML Statement in ‘after trigger’ and not in ‘before trigger’? Thanks KS Kumar
5
votes
2answers
82 views

Why have database rows not been inserted when the debug log says they have?

I have code that creates CaseShare records for the case based on some criteria from another class. The code that creates the CaseShare is called both on update and creation of the case. It works ...
2
votes
1answer
90 views

How to create thousands of records using batch apex

I have a scenario where I have to create 30000 contacts and 15,000 accounts (i.e. 2 contacts per account) in an org. I have been trying to do this by using batch apex but I still have error of "First ...
3
votes
4answers
92 views

DmlException: Update Failed. Maximum Trigger Depth Exceeded

I have below trigger code getting - DML Exception 'Maximum Trigger Depth Exceeded'. Can someone help me please? Apex Trigger trigger updateAoC on Contract_vod__c(after update) { List&...
3
votes
1answer
44 views

Mixed DML Operation Error when Trying to Insert Contact

The basic premise of this code, for those of you who have not seen my 600+ other posts about it, is that it creates a Contact whenever someone creates a User. Certain fields of the contact are then ...
1
vote
1answer
48 views

Upsert with External ID: DUPLICATE_VALUE Error

I'm trying up upsert Asset records with an external Id and am getting the DUPLICATE_VALUE error which makes no sense to me: I want it to UPDATE the record if it finds a duplicate, that's what UPSERT ...
1
vote
2answers
93 views

null values of some fields on inserting data in test class

I have 2 custom object namely ServiceContract & ServiceRole and 1 standard object Account.In service role object,Account is Master-detail relationship to Account and ServiceContract is also Master-...
-2
votes
1answer
115 views

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing

Can any one help me out with this error : System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [OpportunityId]: [...
6
votes
2answers
161 views

DML Limits are reset when?

I have a scenario where I need to update 500,000 Accounts in production to change their Record Type, but I want to avoid writing a Batch class for one-time use. In addition, using DataLoader would ...
0
votes
0answers
19 views

Able to make isactive = false for such users who are manager of some other users

I am able to make isactive=false for such users who are manager of some other users.As per salesforce funtionality i should not be able to make isactive=false using DML as it will throw dependency ...
0
votes
1answer
26 views

Successful DML operation not getting updated in database

I am using below code for batch update : List<Database.SaveResult> updateResults; updateResults = Database.update(listUserDeactivate, false); System.debug('value of users for ...
0
votes
1answer
42 views

Param values are not being passed to the custom controller using commandbutton

Need pro's help. Below are my code snippets. This is what I have tried I have initialized the object Event_Request__c {get; set;} in my controller class. I have created a public method to update the ...
0
votes
1answer
17 views

Will a parent record be updated if you update it's child object (including related fields on the parent)

I can write a SOQL relationship query to lookup Contacts, and at the same time get some data on the related Account. This returns a list of Contacts, each of which has data on it's related parent ...
1
vote
1answer
78 views

delete multiple records from an object [closed]

I want to delete multiple records of an object...How should I do it. public class del_acc { public List<String> sel_id{get;set;} set<id> sid = new set<id>(); List<...
6
votes
1answer
66 views

DML not allowed on NetworkMemberGroup

I am trying to automate the process whereby all profiles are given access to communities. This section when managing a community: As I understand it, this is the NetworkMemberGroup object. I ...
1
vote
1answer
81 views

Performance issue when deleting Opportunity Line Items

I'm writing APEX REST API that creates OpportunityLineItem, Product2, Quote objects, updates Opportunity etc. based on data in JSON format received from external system. During testing I experienced ...
3
votes
2answers
57 views

Links to Documentation for Database.* DML Method? Gone from APEX Docs

So we've got the usual DML statements insert accts; and we've got the database class dml statements, e.g. Database.insert(accts, false). Had a team member ask me a question about the parameter ...
7
votes
1answer
68 views

Combining DML, Callouts and Triggers gives CalloutException

When running unit tests, I'm currently getting: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out The issue is that I have a trigger that ...
1
vote
2answers
200 views

scheduled apex+Too many DML rows: 10001

I am getting this error when i look at my apex jobs UI "Scheduler: failed to execute scheduled job: jobId: 7072000002391Am, class: common.apex.async.AsyncApexJobObject, reason: Too many DML ...
0
votes
2answers
62 views

Update a text field from custom object to Notes Related List

I have a requirement in which I have a custom object. I have a text field in that object. When that text field is filled with a value it show create a note in the related list in which i need to map ...
2
votes
1answer
90 views

Database DML Update partial success versus Data Loader

I have a Trigger On OpportunityLineItem when it's get updated, it will update the Opportunity. I need to update OpportunityLineItem in Bulk. For that, Using Dataloader I kept the (batch size =200) of ...
4
votes
2answers
69 views

How to iterate and update a value of a field throughout considerable number of records?

Attempted to set a value to a field of the account object across 70000 records using anonymous apex execution causes below exception; System.LimitException: Apex CPU time limit exceeded This is ...
0
votes
2answers
78 views

How do I Mass update owner in Contact and Account?

In my ORG I have a 20K Accounts and 50K Contacts. I want to update Contact and Account owner where owner is "Jai" to "Mrugesh". How to update all Contact and Account owner?
0
votes
1answer
33 views

Trigger to check for dupes and get data from them - Insert failed - cannot specify Id in an insert call

So I'm receiving some Accounts from an external source. They could be exactly the ones I already have on the org but this external ones also have some custom Ids that I need to assign to the old ones. ...
5
votes
1answer
130 views

How To Cause DmlException - Delete

I thought I would be able to take a User who does not have delete privileges on an object, delete records from that object, and get a DmlException. No dice. Below are the Case permissions for the ...
2
votes
1answer
87 views

How can I show the progress of a chain batch process?

I have an Apex class that is a controller for a Visualforce page. The VF page has a commandButton that calls a function in the controller that executes a batch process that processes some data, then ...
4
votes
1answer
405 views

Can't Insert User in Test Class

I've created a Trigger on the User object and I'm trying to test creation, update, deletion and undeletion of a User. Starting with Insert DML, I've got the following code: Profile p = [SELECT Id ...
0
votes
1answer
48 views

Delete a Record Using Visualforce

I tried this code i m getting error like this "List has no rows for assignment to SObject" public class delrecords { public string cid{get;set;} public list<contact> conlist{get;set;...
1
vote
1answer
100 views

Use addError method and make a DML operation

The problem that I am having is that I am using addError method in before insert trigger which actually rollback every DML I make including @future method calls, sending email, queueing batch jobs, or ...
3
votes
1answer
143 views

How many DML statements will be execute?

Given the code below, and assuming there are 500 accounts in the system, how many DML statements will be executed? for (List<Account> accounts : [SELECT Id, Name]) { update Accounts; }
1
vote
0answers
64 views

Large time gap in debug log before ENTERING_MANAGED_PKG

When viewing a debug log where the logging level was set to: APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO I am seeing a ...
1
vote
1answer
65 views

Modifying data using SOQL?

I'm using SOQL along with the SOAP API in order to pull a certain set of data to my webpage. However, I want to modify this data (two custom fields) and update the records in Salesforce itself. As I ...
1
vote
1answer
117 views

Unable to Assign Owner to Record

We have a custom object called Lead__c for which I'm trying to execute DML on it to insert a record. However, I need to assign the owner to it. I've got the following query to search for an owner: ...
1
vote
1answer
106 views

Http callout test class “uncommitted work pending” error with no clear cause

We have method EnrollmentUtil.createNewEnrollment which contains a http callout on create of custom object Enrolment__c, and a test class to test this method. I'm trying to figure out how this class ...