Skip to main content
13 votes
Accepted

How do I find merged Records?

In the immediate aftermath (and a short time thereafter), you can find deleted records with a MasterRecordId in the Recycle Bin. SELECT MasterRecordId FROM Account WHERE MasterRecordId != null ALL ...
Adrian Larson's user avatar
  • 151k
11 votes
Accepted

INVALID_FIELD_FOR_INSERT_UPDATE, Account: bad field names on insert/update call: LastName, FirstName: [LastName, FirstName]ge

You're using the wrong record type. I verified that if you were using the correct record type, you would not receive this error. The following code works in my developer org in execute anonymous: Id ...
sfdcfox's user avatar
  • 497k
11 votes

Cannot deactivate record type because it is referenced by other entities

I finally found the answer to this after hours of searching. This happens when you have setup a community audience that references the record type you are attempting to deactivate. It seems as though ...
Clay Chipps's user avatar
9 votes

Account ID to unique Integer?

You can't have a "15-digit integer" that covers all possible Id values. This is because there are 629 possible values in an Id (per object type per pod, plus reserved space), while there's only 1016-1 ...
sfdcfox's user avatar
  • 497k
8 votes
Accepted

Best way to get city, state, and zip fields onto Account object?

There are two standard composite address fields, either of which should suit your needs. BillingAddress BillingCity BillingState BillingPostalCode ShippingAddress ShippingCity ShippingState ...
Adrian Larson's user avatar
  • 151k
7 votes

Using trigger I want to create a case everytime an account is created

Just use Process Builder. There is no readily apparent reason you need to use a trigger for this functionality. Navigate to Create > Workflows & Approvals > Process Builder. Click New. Fill in ...
Adrian Larson's user avatar
  • 151k
7 votes
Accepted

how to get account Name in contact query

use dot(.) between account.name List con = [Select id,name,account.Name from contact]
Vipin Indora's user avatar
7 votes

How to write a soql query will give you accounts that have any contacts and get the contacts

I recommend you read A Deeper look at SOQL and Relationship Queries on Force.com. Everyone who works with Apex probably should. In addition to the Left Inner Join you have in your WHERE clause, you ...
Adrian Larson's user avatar
  • 151k
7 votes

How to Create an Apex class that returns Account objects

method named accountsByState that accepts a state abbreviation as a string and returns a List of Account objects You are not passing the parameter for state. public static List<Account> ...
salesforce-sas's user avatar
6 votes

how to add lastmodifieddate in aggregate list

If you want the 5 most recent Account records: Remove the comma (,) after the Name field in your SELECT clause. Remove the GROUP BY clause entirely if you want individual records. In tandem with the ...
Adrian Larson's user avatar
  • 151k
6 votes
Accepted

SOQL or Report to identify the number of accounts without an opportunity closed within a year

Off the top of my head (for your "Even better, a report") Create a Roll Up Summary formula field on the account Have it get the max date from closed/won Opportunities Then use that field in a report ...
Eric's user avatar
  • 54.2k
6 votes
Accepted

How to query Account object with minimum number of children?

That can be a difficult query since Accounts and Contacts typically have a lot of records. There's a risk of running into the "Too many query rows" exception, but if you don't have too much data at ...
martin's user avatar
  • 12.7k
6 votes

How to stop users from deleting Activities?

You can use an Apex Trigger which leverages the SObject.addError method. You should look into trigger best practices such as handlers, service/domain layer, etc, but the basic idea would look like: ...
Adrian Larson's user avatar
  • 151k
6 votes
Accepted

Allow communities user to see multiple Accounts

Yes, sharing sets now support the Contacts with Multiple Accounts feature. Let’s say you create a community or portal user from a contact that is associated with multiple accounts. You can then create ...
sfdc's user avatar
  • 13.7k
6 votes
Accepted

Find out what instance of SFCC do I have

The Business Manager backend of the instances have color-coded headers: Sandbox = grey Development = green Staging = blue Production = red Additionally on the top left you can see the instance name ...
empiric's user avatar
  • 257
6 votes
Accepted

Account Activity or Object Activity in Journey Builder has limits to update like Data Loader?

I have had this challenge (mass updates from marketing cloud) before and could solve it with the SFSC Bulk API. Journey Builder does not leverage the bulk API, which means JB is considerably slower ...
Jonas Lamberty's user avatar
5 votes

How to make a standard field to not be required

Standard required fields are required. You can't make them optional. I have heard of people making Visualforce pages to set those fields to some value "behind the scenes", but they're still populated ...
sfdcfox's user avatar
  • 497k
5 votes

NPSP did not create an account

When you import contacts that are donors into the NPSP, there's a NPSP Data Import Object that you want to import them into first after which you can run the Nonprofit Starter Pack Data Importer Tool ...
crmprogdev's user avatar
5 votes
Accepted

Is it possible to retrieve list of Accounts which has more than 100 contacts associated to it using a single SOQL?

Solution 1 You can do this in single soql via : Select AccountId from Contact group by AccountId having count(Name) > 100 Solution 2 You have to create a roll-up summary field on account object ...
Pragati Jain's user avatar
  • 1,580
5 votes
Accepted

Does Salesforce strictly enforce the picklist as an ENUM?

You can configure custom picklist fields to restrict values to only those specified in the metadata. Any picklist field that uses the Global Picklists feature must have this option enabled. Most ...
Adrian Larson's user avatar
  • 151k
5 votes
Accepted

Deserializing an Account throws an error

It's because the query returns a List<Account> unless you specify it somewhere as a single Account record. Works Account data = [SELECT Id, Name FROM Account LIMIT 1]; system.debug(JSON....
Adrian Larson's user avatar
  • 151k
5 votes
Accepted

Get account by user id

Looking at the User object fields in SFDC ,AccountId and ContactId fields are populated only if your user is a portal/community user Also you can directly use the AccountId field instead of using ...
Mohith Shrivastava's user avatar
5 votes

SOQL or Report to identify the number of accounts without an opportunity closed within a year

If you want to find records which were closed within the last 365 days (2016-02-08 through 2017-02-08), use: WHERE CloseDate = LAST_N_DAYS:365 When you filter with <, you look for anything before ...
Adrian Larson's user avatar
  • 151k
5 votes

How to query Account object with minimum number of children?

You can try following query: SELECT Id, (SELECT Id FROM Contacts) FROM Account WHERE Id IN (SELECT AccountId FROM Contact) What you have missed is having AccountId in outer join. Update: If ...
Raul's user avatar
  • 18.8k
5 votes
Accepted

System.QueryException: No such column 'BillingStateCode' on entity 'Account'

If you are getting this error in apex class then I suggest you to update the API Version of your class. You will get this error if your Apex Class version is less than 27. Update the API version to ...
Ratan Paul's user avatar
  • 22.7k
5 votes

Method Does Not Exist error message

You're calling a method with a single Account parameter: Parent_Subtract.executeSub(acct); but this method is defined to take a List<Account> as its parameter: public static void executeSub(...
David Reed's user avatar
  • 93.2k
5 votes
Accepted

How to know my account type? Marketing cloud

I don't think this is a dumb question since the information isn't readily available in the platform, I have wandered in the beginning too. The easiest way that I can think of is a chrome extension ...
Brad Sapkota - altus.digital's user avatar
5 votes
Accepted

When to use Account vs. AccountChangeEvent

AccountChangeEvent is a Platform Event, specifically a Change Data Capture (CDC) trigger. It's always "after insert" because we're handling an AccountChangeEvent Platform Event object, not ...
sfdcfox's user avatar
  • 497k
4 votes
Accepted

How to trigger max value of field from multiple child objects onto parent account?

Ishwar Mete's answer is close, but continues to have some issues. I do agree that using SOQL Aggregate Functions is the way to go here. Aggregate Functions: Are provided by Salesforce, so their ...
Derek F's user avatar
  • 62.7k
4 votes

How to make a standard field to not be required

If I'm not mistaken, the only required "standard field" on Account by Salesforce is Name. This must be a custom field. You can make standard (non required) and non-standard fields optionally required ...
crmprogdev's user avatar

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