21
votes
Accepted
How to get an 18 digit ID from 15 digit ID using SOQL
To convert it to 18 digits you can simply set it to an Id type variable:
Id someId = '001J000001eun1Q';
Which will automatically convert it for you:
system.debug(someId); // 001J000001eun1QIAQ
...
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 ...
Community wiki
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....
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 ...
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\'');
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 = '...
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 ...
9
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:...
9
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
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 ...
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 {
...
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 ...
8
votes
Formula Field Changing the Date to Today
Your formula evaluates every time you retrieve it's value. So at any point in time your formula will evaluate today() which will be the actual date/time.
The solution would be to create a workflow ...
8
votes
Accepted
Does salesforce assign Ids of deleted Records to new records?
No, new records always receive new IDs, and they are generally allocated in sequential order within the same transaction (but, not guaranteed, so do not depend on that behavior). The only exception to ...
8
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 ...
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 ...
7
votes
Accepted
Get the ID of a lookup field for Onclick Javascript Button
I figured it out, you need to add 'Id' to the end of your field before '__c'. Here an example of my code (each of these fields is a lookup field other than the project ID):
{!REQUIRESCRIPT("/soap/...
7
votes
Accepted
Need Help in Making Dynamic Sooql using Like Operator
In your case
String tempInput ='\'%' + inputValue2 + '%\'';
soqlRAD2 = soqlRAD2 + ' and BR_Opportunity__r.Account.name Like :'+tempInput ;
Just remove colon :
like this
String tempInput ='\'%' + ...
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, ...
6
votes
Accepted
Entity Id Across Multiple Orgs
Behavior of custom object prefix ID when using Change Sets
Knowledge Article Number: 000176809
Depending on the type of Sandbox you are using, a custom object prefix ID might change upon deploying ...
6
votes
How can I convert a 15 char Id value into an 18 char Id value?
Python version
import string
import sys
bin_lookup = {
'00000':'A',
'00001':'B',
'00010':'C',
'00011':'D',
'00100':'E',
'00101':'F',
'00110':'G',
'00111':'H',
'...
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 ...
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....
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 ...
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 ...
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 = :...
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 ...
5
votes
Accepted
invalid ID error using SOQL to get field from related record
Id fields cannot be compared with the '' value. If you need to check for blank , then use "null" instead of ''.
So change your check like this :
system.debug('SystemChangeRequest View/Edit PAGE ...
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 ...
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, ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
salesforce-id × 653apex × 229
visualforce × 72
soql × 53
community × 48
trigger × 36
salesforce1-app × 31
lightning-aura-components × 30
lightning × 28
lightning-web-components × 22
javascript × 20
data-loader × 20
unit-test × 18
custom-object × 18
query × 17
force.com × 16
integration × 15
marketing-cloud × 14
lookup × 13
rest-api × 12
visual-workflow × 12
record × 12
email × 11
list × 11
sobject × 11