Skip to main content
13 votes
Accepted

Can Not Update SFDX

The documentation states: If You Installed the Salesforce CLI Using the Installer To install the latest Salesforce CLI version, run: sfdx update If You Installed the Salesforce CLI Using npm The ...
Raul's user avatar
  • 18.8k
8 votes
Accepted

How to do a dependent callout from a future callout

Instead of using @future, you should use Queueable Apex. Queueable Apex, lets you chain jobs. To allow callouts, you need to specify Database.AllowsCallouts public class AsyncExecutionExample ...
Daniel Hoechst's user avatar
7 votes
Accepted

Update records using map values

You can do it like this: // Your map Map<Id, String> m = new Map<Id, String>(); // Update needs to know the type so create objects of the right type Opportunity[] updates = new ...
Keith C's user avatar
  • 136k
6 votes

Is it possible to update an existing opportunity in Salesforce using apex SOQL query?

No, SOQL (Salesforce Object Query Language) is a query language. It allows you to pull data from the database. If you want to push data to the database, you use DML (Database Manipulation Language) ...
Adrian Larson's user avatar
  • 151k
6 votes

Update an object field

Someone will only have to come include that field in the query if they actually need to do something with it in your code. You do not need to (and absolutely should not) include every field on your ...
gNerb's user avatar
  • 9,510
6 votes

UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record or 200 records - Error even after using FOR UPDATE

You'll want to read this answer for more information, but the gist is that just because you use FOR UPDATE, does not mean you will eliminate this error. Instead, if the lock does not get acquired ...
sfdcfox's user avatar
  • 497k
6 votes
Accepted

can too many validation rules cause a performance issue with large data - Apex CPU Time?

Apex Triggers, Flows, and Process Builder consume CPU limits, but validation rules, workflow rules, matching rules, duplicate rules, assignment rules, escalation rules all do not count towards the CPU ...
sfdcfox's user avatar
  • 497k
6 votes

Is my after insert trigger efficient and safe to port to production?

No, you have not properly bulkified your code. Bulkification 101's most important lesson is to aggregate filter values, query before your loop and put records into a Map, and update values after your ...
Adrian Larson's user avatar
  • 151k
5 votes

Lead before update runs on insert

A typical reason for this is that you have Lead Assignment rules. Once those execute, a new owner is assigned and hence the Lead object is updated. You can see this in the debug log if you enable ...
cropredy's user avatar
  • 72.1k
5 votes
Accepted

Update an object field

If you already have an Id value, you do not have to do a query to update the value. Instead you construct an instance using the Id you have and set the field value you need and then pass that object ...
Keith C's user avatar
  • 136k
5 votes
Accepted

Adding to a List changes all previous additions

You're doing things in a kinda funky way, and that's leading to your issues. A list that holds SObjects (such as your List<NFP_Lead_Account>) will hold references to the SObject instance. So, ...
Derek F's user avatar
  • 62.7k
5 votes
Accepted

move all child records from one account to another efficiently

It sounds like you want to merge two records. The Database.merge method (or the merge DML keyword) will move all children from the bad account to the good account, and delete the bad account. If you ...
sfdcfox's user avatar
  • 497k
5 votes
Accepted

workbench cvs update set field to null

There is a setting in work bench that you need to check called 'Insert Null Values'. This should allow you to do updates with null values.
Brian Simpson's user avatar
5 votes

Does Database.SaveResult, Database.DeleteResult, etc. implement a public interface?

No, they do not implement a common interface. As a workaround to this, I created a wrapper class that does this: class DmlResult { Id recordId; Integer rowIndex; Boolean success; ...
sfdcfox's user avatar
  • 497k
5 votes
Accepted

|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object on my Apex Trigger

Others have covered how to address the Null Pointer Exception (NPE for short). I'd like to cover how to determine the cause of an NPE. When debugging NPEs, I like to keep in mind the famous saying of ...
Derek F's user avatar
  • 62.7k
5 votes
Accepted

Why does my trigger not update the record?

Ideally for such kind of requirements, it would be better if you can build the logic in before update event rather than after update event, in which case, there won't be any need to handle the ...
Vijay Ganji's user avatar
  • 6,656
5 votes
Accepted

Trying to write a trigger before delete on child to update a value in parent object

If I had to take a guess at what your issue is, I'd say that you're probably getting a Duplicate object in list error. You're not seeing that error because you are smothering any exceptions you ...
Derek F's user avatar
  • 62.7k
5 votes
Accepted

Writing test class for order activate. Error: Required fields are missing: [PricebookEntryId]: [PricebookEntryId]

Pricebook entry is missing from test data. You need to create test Pricebook entry. PriceBookEntry stdPriceBookEntry = new PriceBookEntry(); stdPriceBookEntry.Product2Id=p.Id; //Product Id ...
Rahul Gawale's user avatar
  • 12.2k
5 votes
Accepted

Send only udpated fields instead of all the field information

You can use the CDC (Change Data Capture) to get updates only on updated fields. You could also write manual code (Apex) to create a change delta, although this might require a lot of CPU time ...
sfdcfox's user avatar
  • 497k
5 votes
Accepted

Executing the SFDX Update command to update the CLI to latest version is not working

So ultimately, I posted comment on a similar bug posted on GitHub CLI Repo - link - and got a resolution from there by another user suggesting to uninstall a plugin on my local machine. Found out that ...
VarunC's user avatar
  • 6,000
4 votes

Why I can't change OwnerId to null or empty?

All Records in Salesforce must have an Owner which is either a User or a Queue, if you try and set OwnerId to Null or blank "", this will always fail as the field is mandatory therefore Null is not an ...
Dave Humm's user avatar
  • 5,111
4 votes
Accepted

How to update a record but not overwrite a specific field

Okay so if you can't update the function to accept & return the acc variable because it's a trigger or some other secondary process, then it might be easier to insert only the values you want to ...
marktuk's user avatar
  • 116
4 votes
Accepted

How to update record after some time based on certain criteria?

See the Time-Based Workflow FAQ: Will the pending actions in the queue ALWAYS trigger? No. Time-dependent actions remain in the Workflow Queue until processed or the rule criteria for the ...
Adrian Larson's user avatar
  • 151k
4 votes
Accepted

Error when Update QueryDefinition with SOAP API

To successfully update a QueryDefinition using SOAP, I had to include (1)the account's MID and (2)the query activity's ObjectID. I found the ObjectID by hovering over the link to the query activity in ...
Mark G's user avatar
  • 1,559
4 votes
Accepted

NullPointerException: Attempt to de-reference a null object in a batchclass

You can't directly set these parent fields from the Asset record. You have to query for the related Account and set it's Actief_onderhoud_Design_Solutions__c directly. So you'll prob need to do ...
Caspar Harmer's user avatar
4 votes
Accepted

How to merge methods into one

You can merge the two methods into one like this way. public static void updateTableMergeMethod(Map<Id, Team__c> newTeams, Map<Id, Team__c> oldTeams) { Set<Id> ...
Santanu Boral's user avatar
4 votes

Adding to a List changes all previous additions

So to give a complete overview of the error and the problem at hand, the error coming back is telling you that the list contains multiple references to the same object so you're inserting a list of ...
Thuesmann's user avatar
4 votes
Accepted

Apex Trigger Update Case With Account Id Bulk

This is probably more appropriate for codereview.stackexchange.com (I am making a point to check the [salesforce-apex] tagged questions over there), but here's what I see. You don't have a WHERE ...
Derek F's user avatar
  • 62.7k
4 votes

|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object on my Apex Trigger

If you cannot guarantee that a value is not null, you typically add a null check: MyObject__c record = myMap.get(someKey); if (record != null) { record.MyField__c = someValue; }
Adrian Larson's user avatar
  • 151k
4 votes

How to Mass Update Records Without Changing the Last Modified By Field

You can only do this upon inserting records. A script like what you're talking about will always modify the audit fields for Last Modified By and Last Modified Date. You'll want to vote on this idea.
sfdcfox's user avatar
  • 497k

Only top scored, non community-wiki answers of a minimum length are eligible