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
18 views

Standard Case Notification when Owner is Changed via Visualforce page not working?

Currently we have a setup wherein when the owner of a case is updated via a Visualforce page. The problem is the Standard Case Notiifcation when the owner is changed is not being sent out when the ...
-1
votes
1answer
30 views

Can I update data without updating the LastModifiedDate for a particular transaction?

I am migrating over legacy fields within a Salesforce org, but not performing any actual data updates (just moving some fields around). For this reason, I'd like to preserve the existing ...
0
votes
0answers
63 views

Too many DML statements: 151 - no DML in a for loop (that I can see)

I'm trying to build a newsletter manager that allows users to easily update and clear newsletter campaign members based on their subscription and region without having to run multiple reports. I've ...
4
votes
1answer
43 views

Database class commit

Why does Database class not provide commit method so that we can commit explicitly as well while in a transaction as we can do a rollback.
1
vote
2answers
41 views

MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object

I've written a trigger that will add users to a public group but can't seem to get my test class to work. I have 100% code coverage but the test keeps failing with the Mixed DML Operation error. ...
1
vote
1answer
17 views

How to update Latitude/Longitude in salesforce Organization object?

I got DML not allowed on Organization error when I try to update the object in apex code. I checked the documentation. It looks like Organization object can be updated. Does anyone know why the ...
1
vote
2answers
22 views

How can I add a role and use apex managed sharing all at once?

Question is in the title. For context, when a certain record is added, we would like to create a role (named after that record) and share it with that newly created role. Because of that, the flow ...
0
votes
0answers
29 views

Update DML statement with Regular Expression match between characters

I'd really appreciate some help on this trigger please - here's what I'm trying to do and the code so far. Thanks in advance for your help. Custom Object: NVMStatsSF__NVM_Call_Summary__c Field: ...
1
vote
1answer
71 views

error in Test Class System.DmlException: NVALID_CROSS_REFERENCE_KEY

Getting this error in Test Class System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, only portal users can be associated to a contact: [] ...
0
votes
1answer
34 views

Database.rollback() risks and alternative

I've inherited some complex logic that does several different DML actions within the same (fairly long) method and if there are failures I need to revert everything that's been previously done. The ...
0
votes
1answer
16 views

Current transaction identification

I'm working with webservice callouts and DML's at the same time. Is it possible to identify the current transaction like getting its ID ?
2
votes
1answer
64 views

Update based on csv data

I have a requirement to update records of custom object Incident_abv__c if the value of it's Name field in present in csv. I have below class and page to do the same. But when I click the Read csv ...
3
votes
1answer
45 views

Compiled successfully, update not happenning

I have below batch class that is not doing DML update operation also no error in debug log. Can someone please help me here? Batch class: global class AckCallUpdatenew implements ...
0
votes
2answers
139 views

Too many DML rows: 10001 issue

I have a trigger that works perfectly in my sandbox. When I try to deploy, I get the following error message: receiving_Tests.receiving_Trigger_Tests(), Details: System.LimitException: Too many ...
5
votes
1answer
719 views

Too many if statments?

So the Apex docs say you have to set the value of the master record if you want to retain the discarded account field values before the merge operation. Is there a better way to do validation for a ...
-2
votes
2answers
46 views

Continue not working properly

I have below code where I do a check if a list value is contained in a set then jump to next iteration without executing the next statement that is update. Here I am using 'continue;' statement in ...
1
vote
0answers
26 views

Update fails without error

I have below class where update on mycallsInc not happening. Can someone please help me? public void Publish() { List<Incident_abv__c> selIncs = ...
0
votes
0answers
15 views

Track records update based on User entry

I have a requirement to show five sections with different SOQL querry records. Now one common field in all of them is an input text PICKLIST field. While doing update I want to track only those ...
0
votes
1answer
59 views

Update list values in an input text field

I have below code to update the input text field value for OUTCOME field from the User. My list update is failing to happen without throwing any exception. Please can someone help me here? My ...
3
votes
0answers
61 views

Add Error on standard list view

does someone know how to show an error in an object's listview after a dml operation? I have written a simple trigger that prevents user to delete closed opportunity List<Opportunity> ...
1
vote
1answer
34 views

Copy EventRelation data to a custom object

I'm trying to add a field to track event attendance (not just accepted response). I've created a custom object and a visualforce page. The problem I am having is copying the EventRelation data to ...
2
votes
1answer
65 views

Upserting objects in Apex: can I assert which have been inserted / updated?

I'm upserting a list of custom objects in an Apex controller that are retrieved on demand from an external source. My object has an external identifier field used to help the database call determine ...
4
votes
2answers
68 views

Will SFDC manufacture batches from concurrent operations?

So, like all SFDC developers worth his/her salt, I know when writing triggers and other code, we need to bulkify. And I have a pretty good handle on how to do that, so I am not asking about that. ...
1
vote
1answer
195 views

System.SObjectException: Field is not writeable: CampaignMember.ContactId

Can anybody help me figure out why Salesforce is saying the Campaign Member ContactId field is not writeable? I have Dedupe logic that runs on Contact after insertion, if it matches an existing ...
1
vote
2answers
140 views

Problem with Database.update()

I have some accounts to update but some validation rules can failed. So to avoid this I use the Database.update() function to update accounts even if some DML exception occur. try { ...
2
votes
1answer
102 views

Sharing Records

I have an org that was recently updated to API 32, which broke some triggers that create Sharing Records. This code worked previously to the update to API 32. public void ...
4
votes
2answers
162 views

Database Class Methods

A noobie question. Is Database.Update bulkified by itself ?. I know it is similar to "update" but just wanna confirm that this alternate version of DML is auto bulkified. For example let us assume ...
0
votes
1answer
61 views

@future solves ERROR: MIXED_DML_OPERATION but Batch fails

A user is automatically created in the backend whenever a contact is created in the sf console. A custom field, DivisionCs is filled during that automated process. We want the same field to be updated ...
1
vote
1answer
18 views

Cases added with Prefix as “RE”.How to display them in a while Statement

We do get case added with the Prefix as " RE " or "FW "So we give them in a while stmt ,as : while(c.Subject.startsWith('RE:') || c.Subject.startsWith('FW:')) Similarly case added with the Prefix ...
7
votes
1answer
139 views

Database.DMLOptions - How to prevent Chatter Group Auto-Follow trigger from generating email

Currently I have a trigger which auto-follows specific groups in our organization when a new user is brought onboard. The auto-follow trigger feature works great! However, we have quite a few groups ...
2
votes
1answer
100 views

Mass update: Required field is missing

I deployed a trigger and trying to update all records to populate custom field of existing records with value ( account object ). Everything works perfect unless I get the following error: ...
2
votes
1answer
99 views

Why record is removed on exception thrown

I'm inserting and updating a new record before throw an exception like this: Operation__c o = new Operation__c(ok__c = false,Step__c = 'test1'); insert o; system.debug(o); //this shows the Id try{ ...
5
votes
1answer
272 views

'After' trigger's SOQL - will query fetch current value of the inserted/updated record?

I want to get data from children objects and populate field at parent object. I used after insert & update trigger to get the information. If I run a query on inserted/ updated object in a ...
2
votes
0answers
39 views

How to update the current login user

I have a custom field over my user object. And I want to update this user by the contact id from apex. How can i update the user record in salesforce. Because when I trying to update the field of ...
1
vote
1answer
34 views

call dml insert listofSObject from a controller that is referenced in apex page

Is it possible to call dml operations like insert list_SObject ; inside a controller method that is refrenced in visualforce page not some trigger class? please give some references.
0
votes
2answers
54 views

Trigger is not updating a lookup field

Resolved. Object's sfid wasn't created yet. Changed the trigger to after trigger. I've looked at other posts, but for some reason I cannot find a solution. Basically, when a new object is inserted ...
1
vote
1answer
34 views

Is there a predetermined order that Database.SaveResult is returned?

Let's pretend the scenario below: List<Account> acc = new List<Account>{...}; List<Database.SaveResult> results = Database.insert(acc, false); Will the Lists have associated ...
1
vote
1answer
33 views

Why am I getting SaveError: Variable does not exist: AssigneeId?

I have entered the following code entered in the Force.com IDE: @RestResource(urlMapping='/PermissionSetAssignment2/*') global with sharing class PermissionSetAssignment { @HttpPost global ...
3
votes
2answers
103 views

Why is my locked record editable?

Why is my record locked? The record that the class below creates, when shown in detail view, has the 'locked' icon, and appears to be locked at first view, but- Why can I edit the locked record (Even ...
6
votes
0answers
73 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 ...
2
votes
2answers
127 views

What to use for performing operations on multiple records at once, Apex REST class or Bulk API?

I need to insert/update/delete a variable number of records at a time from a webapp (so from javascript), are there reasons to choose the Salesforce Bulk API over writing a custom Apex REST class to ...
2
votes
1answer
29 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?
-1
votes
1answer
81 views

Realtime scenerios on dml and database class methods [closed]

can anyone provide links or tasks or whatever possibilities on dml operations otherthan force.com developer guide. plz... As i understood concepts on insert,update,upsert,delete and also database ...
2
votes
1answer
75 views

Is it bad to update a a list of a size greater than 200 in DML

I am reading the existing code in the project. In the code: if(aUpdates.size() + aList.size() > 200) { update aUpdates; aUpdates.clear(); aUpdates.addAll(aList); } else { ...
1
vote
3answers
245 views

Changes to trigger.new upon Sobject Event within before update are not sticky

I have a custom object that creates a calendar event via a trigger and it works fine. However, if the user attempts to change calendar event fields from the calendar edit feature, I want the fields to ...
0
votes
1answer
170 views

Apex Error: Too Many SOQL Queries: 101 [duplicate]

I am currently trying to update a set of data, but I am receiving the error "Too Many SOQL Queries: 101". From what I have seen while searching around, this is normally an error that occurs while ...
2
votes
1answer
146 views

DMLOptions 'useDefaultRule' for an account's update - not working

I'm trying to assign DML options to an account's update. It's working with the insert, but not wit an update. Here is the code I'm using: Database.DMLOptions dmlOpts = new Database.DMLOptions(); ...
4
votes
1answer
326 views

New Customer Portal user email even when triggerUserEmail = false

I'm trying to write an Apex web service that can create a customer portal user. After creating the user, there is a separate step which does a password reset for the user and sends them an email. The ...
0
votes
1answer
68 views

Updating a record without DML

I am writing an after update trigger on OpportunityLineItem that will update an opportunity based on values retrieved from it's respective line items. By sheer accident, I forgot to include the ...
1
vote
1answer
147 views

List Exception caused by trigger

I have some code in a trigger that works when tested, and works in my sandbox, when I get it into production every time something happens where the trigger should go off, I get this error: Apex ...