Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs
18 votes
Accepted

What are the Salesforce Pod ID to instance mappings?

As per Converting the Salesforce Pod Id to ServerUrl/Name, I started the mapping process from the source code of Workbench. That list however is largely out of date. As a community resource I've ...
14 votes
Accepted

Converting uppercased 18-digit Id to valid Id

I ported Daniel Ballinger's answer here to Apex: static String CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ012345'; static List<Boolean> getBitPattern(String c) { Integer index = CHARS.indexOf(c....
Adrian Larson's user avatar
  • 150k
13 votes
Accepted

What is the value of the first and final record id for an object?

Most of what you need to know is covered in What are Salesforce ID's composed of? In short, only the last 9 characters of the ID are incremented from record to record. E.g. 0010a0000000001 to ...
Daniel Ballinger's user avatar
13 votes
Accepted

Convert Datetime to string in GMT format?

Use DateTime's formatGMT to format the time according to your specs in GMT. String formatedDt = dt.formatGMT('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'');
sfdcfox's user avatar
  • 494k
10 votes
Accepted

Check if a record exists without knowing its type

You just need to make an Id instance from your String value, which you can do with Id.valueOf(stringValue). If you want to simply get a Boolean whether or not a corresponding record exists, you can do:...
Adrian Larson's user avatar
  • 150k
10 votes

Converting uppercased 18-digit Id to valid Id

Parallel to Adrian's response I also cooked up my own version for reference; public static Id correctCapitalizedId(String input) { String keyString = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ012345', result = '...
Koen Faro's user avatar
  • 773
10 votes
Accepted

getting the owner's name from a SOQL query

You can access the name of the owner using Owner as the name of the relationship between the objects. Owner.Name, Account__r.Owner.Name
martin's user avatar
  • 12.7k
10 votes

Distance between Salesforce ID indicates activity of other tenants

No. IDs are not always sequential, you don't know the volume of records created by other tenants, IDs are globally unique, and records are deleted all the time. Having worked at Salesforce, I got ...
DavidSchach's user avatar
  • 5,903
9 votes

Shared API User

This is a pretty common approach on small instances (and some large ones too). I usually name the user "Integration User"; some orgs call it "System" or something like that. It's ...
David Reed's user avatar
  • 93.1k
9 votes
Accepted

How to choose using Collection<Id> rather than Collection<String>, or the opposite?

Both String and Id are primitive data types in apex. Consider below scenario: public class poc { static List<Id> ids = new List<Id>(); public static void check() { try { ...
salesforce-sas's user avatar
9 votes

Is There a Way to Know if an Id Exists Without Querying?

The answer is NO A far better practice is to store API names in custom settings/custom metadata and query for the resource by apiName in the code: API Names are more transparent than IDs Custom ...
cropredy's user avatar
  • 71.7k
9 votes
Accepted

How to pass the record id to controller method from LWC

When you have an LWC that works in Lightning Record Pages, it can automatically receive the record ID by declaring an API property: @api recordId; The LWC framework ensures this gets set when the ...
Phil W's user avatar
  • 36.7k
8 votes
Accepted

When do we need to mention Id explicitly in SOQL querry

There is no "benefit" as such by including it when your SOQL contains one or more other fields being queried as it is always returned in Apex queries, whether it is specified in the query or ...
TSmith's user avatar
  • 5,032
7 votes

Add a custom field to multiple objects

Assuming all the objects are already created, you could create a file that simply contains the one field definition you need, copy it, and deploy it. I'd say this task is probably easiest with Ant, ...
sfdcfox's user avatar
  • 494k
6 votes
Accepted

Duplicate ID error - Don't understand other explanations

Ok, there's a few things going on here to sort out. 1. Query in a loop you have a query inside of a loop. There are very few good reasons to ever do that, and you should view it as an anti-pattern ...
Matt Lacey's user avatar
  • 25.6k
6 votes
Accepted

Get Contact Record from Account List

List<Account> accounts = [Select Id,(Select Id,FirstName, LastName From Contacts), Name, BillingCountry from Account]; for(Account objAcc:accounts ) { //iterate over contact. here objAcc....
Ratan Paul's user avatar
  • 22.7k
6 votes

Salesforce Lightning: How can i get session Id of current user in Salesforce lightning component?

Take a look into the document mentioned here .You cannot use the session obtained from userinfo to make REST API calls using the @AuraEnabled methods for Security reasons . Salesforce recommends ...
Mohith Shrivastava's user avatar
6 votes
Accepted

Salesforce Lightning error handling

It's a known issue. You can find the details here. Custom error messages not displayed in Lightning Experience when uploading files Summary:- Server error messages (added via addError() for ...
sanket kumar's user avatar
  • 15.4k
6 votes

Illegal assignment from Id to List

As it says, you're trying to assign an Id (a scalar value) to a collection. You need a loop for this: Id[] voterIds = new Id[0]; for(Vote__c record: [SELECT Id FROM Vote__c WHERE Suggestion__c = :...
sfdcfox's user avatar
  • 494k
6 votes
Accepted

Assigning SOQL results to a set

You can instead get the results into Map and get the keyset from Map to get Set<Id> Map has a constructor which takes List<sObject> and creates a instance of Map with ID as Key and ...
Vijay Ganji's user avatar
  • 6,646
6 votes

How to get list of all sobject records modified today in the system?

Simpler way? well yes and no. We have Database.getUpdated method that returns Id of records updated in a particular time span. It takes sObject Type , start date and end date as arguments and returns ...
Pranay Jaiswal's user avatar
5 votes

Test class to run any Organization

Maybe you could calculate "on the fly" your account fields using Map<String, Schema.SObjectField> mapFields = Schema.getGlobalDescribe().get('Account').getDescribe().fields.getMap(); then you ...
Agusnovak's user avatar
  • 189
5 votes
Accepted

'TEXT()'. Expected Number, Date, DateTime, Picklist, received Lookup(User)

You'd want to use the relationship instead: Account.Customer_Success_Rep__r.FirstName & " " & Account.Customer_Success_Rep__r.LastName TEXT is specifically for converting numbers, dates, ...
sfdcfox's user avatar
  • 494k
5 votes
Accepted

Unable to fetch queues in Live agent button + omni channel

Queue->select the queue which u r using in omni ->Supported Objects-> select Live Agent session and Transcripts. Then it will works
phani's user avatar
  • 66
5 votes

Shared API User

Yes, you can share a user across multiple integrations. However, do be aware that the governor limits do outline a few special limitations. For example, there is a limit of 50 concurrent query cursors....
sfdcfox's user avatar
  • 494k
5 votes

Distance between Salesforce ID indicates activity of other tenants

The Id values are allocated in batches within each pod (instance), so there's not even a guarantee that that you'll have strictly sequential numbers even in the same insert transaction. This also ...
sfdcfox's user avatar
  • 494k
5 votes
Accepted

Does Userinfo.getUserId ALWAYS return 18 digit ID?

From my observation, UserInfo.getUserId should always return an 18-character ID. However, the return type is "String" for this method, so there is no guarantee that the return value will always be the ...
sfdcfox's user avatar
  • 494k
5 votes
Accepted

What is the best value to use for an Id of a specific SObjectType that matches no records?

You can use all zeroes (e.g. keyPrefix + '0'.repeat(12)). It will never match an existing or future ID. Depending on your use case, you can also generally just use '0'.repeat(15), which is what ...
sfdcfox's user avatar
  • 494k
5 votes
Accepted

First exception on row 0; first error: INVALID_ID_FIELD, Invalid entity type for whatId

Activities are not enabled for the Invoice object. Go to the Object Manager, and edit the properties of the object to allow activities. Alternatively, use mail.setSaveAsActivity(false); so that no ...
sfdcfox's user avatar
  • 494k
5 votes
Accepted

How to get id from concatenation of string in loop

I'm pretty sure what you're looking for is: String custMet = 'BillToId__c'; String idStr = (String)invoice.getSObject('BillingAccount__r').get(custMet); getSObject returns the instance of the ...
Antonio Manente's user avatar

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