21
votes
Accepted
Get Label For SObject API Name
You can get the label using the DescribeSObjectResult:
DescribeSObjectResult describe = SObjectType.MyApiName__c;
system.debug(describe.getLabel());
Another common syntax is:
DescribeSObjectResult ...
21
votes
Accepted
About the 10 custom objects limitation for community licenses
There are no technical restraints regarding the ten object limit. This is actually mentioned in the documentation somewhere. However, if salesforce.com finds out (however that may be), you would be in ...
19
votes
Accepted
Custom Metadata vs. Custom Objects in Managed Package
Here are some "advantages" vs using a Custom Object:
Can be Deployed
Can use Field Definition or Entity Particle to create references to Custom Object Metadata
Retrieve doesn't cost against ...
16
votes
Accepted
Working with SObjects instead of concrete custom objects (i.e., abstraction in apex)
Mechanics
You need to use the get and put methods. Each method supports both String and SObjectField as the parameter type:
// terse
myObject.put('UniqueId__c', myObject.get('ExternalId__c'));
// ...
16
votes
Custom Metadata vs. Custom Objects in Managed Package
A reason I haven't seen articulated yet applies specifically to the managed package context:
Packaged, protected Custom Metadata Types are an ideal solution for secret storage in a managed package ...
14
votes
Accepted
Can someone please explain what is meant by sObject?
An SObject represents a specific table in the database that you can discretely query. The API Name is what you reference as ending in __c. Standard SObjects have names like Account or Opportunity, ...
13
votes
Accepted
Apex object field for reverse lookup
Yes. You are looking for a Left Outer Join, where the type of query you first reference is a Right Outer Join. Your query might look like:
SELECT (SELECT Id FROM Awards__r) FROM Person__c
You can ...
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 ...
12
votes
Accepted
How to identify look up relations to an object in Salesforce
You could get this with apex describe methods:
for ( Schema.ChildRelationship scr : Account.sObjectType.getDescribe().getchildRelationships() ){
system.debug('');
system.debug('**** Child ...
12
votes
Accepted
Customize error message for trigger and display error message below the field
You can add an error to a specific field using the addError method as follows:
SObject someRecord;
someRecord.SomeField__c.addError('Custom Message');
//or
someRecord.someField__c.addError(...
12
votes
Accepted
How to initialize sObject with Relational fields?
You need to use the name pointing reference:
MyObject__c record = new MyObject__c();
record.Parent__r = new Parent__c(Name='Populated');
The above is functionally equivalent to putSObject:
...
10
votes
Accepted
Insert multiple sObjects in single DML call
You need to use a related field Contact__r to associate the Contact to AccountContact__c.
Try below code,
List<sObject> records = new List<sObject>();
records.add(new Account(...
10
votes
Updating an object API name when referenced by code - impossible!
I think developers just become resigned to how painful simple refactoring like changing a name is after a while, either accepting the pain involved or choosing to just leave the bad name. Or choosing ...
10
votes
Accepted
Get Object API name of any Lookup field
Use Schema.getGlobalDescribe() method that accepts String as API name of object and then use getMap() method to get map of SObjectFields
String objectName = 'Opportunity';
String fieldName = '...
9
votes
How do I get the list of fields of sObject
One liners:
Sobject__c.sObjectType.getDescribe().fields.getMap().keySet()
Or for dynamic queries:
String.join(new List<String>(SObject__c.sObjectType.getDescribe().fields.getMap().keySet()), '...
9
votes
Insert multiple sObjects in single DML call
You need to use the name pointing reference. Here, that would be Contact__r.
It might be more clear if you look at how it works if you set the value dynamically: you can either call set with the Id, ...
9
votes
Accepted
Roll-up summary implications and behind the scenes calculations
There are following issues in your design.
Account data skew:
If an Account record has more than 10,000 child records then it is called Account data skew. It can also be broadly called as Parent-...
9
votes
Cannot Change Object Permissions?
You are limited to the settings that are editable on standard profiles. This includes the Standard User profile, which does not allow you to edit the object level permissions.
You must clone the a ...
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
Accepted
getReturnValue returns undefined
The problem is the name of the variables here .Be always careful with naming your actions on the server and the client side .
getCustomObjects: function(component) {
var action = component.get('c....
8
votes
Accepted
How do I count objects available in a Salesforce organization?
You can easily do this using Global Describe
map<String, Schema.SObjectType> GlobalMap = Schema.getGlobalDescribe();
for (Schema.SObjectType Obj : GlobalMap.values()) {
Schema....
8
votes
Accepted
Is there a way to see all recent changes in an org
Monitor Setup Changes
Setup Audit Trail tracks the recent setup changes that you and other admins have made to your org. Audit history is especially useful in orgs with multiple admins.
To view the ...
8
votes
Validate if a custom object or custom settings is used anywhere
What you're looking for is this feature (dependency API), but it's not available publicly yet. For now, the only sane way to do a check is to use a metadata deployment with a "check-only" option to ...
7
votes
How to know, existing object limit for my current edition
Navigate to Setup -> System Overview.
Here you will be able view Number of Objects you can create in your org.
Custom Object Limits as per the Salesforce Doc
Note:The system overview page shows ...
7
votes
Accepted
"No such column 'New_Field__c' on entity 'Custom_Object__c'" when querying Object deployed via Change Set
You almost certainly omitted permissions to read this field for your profile. Edit the Field Level Security and make sure you have at least Read access.
7
votes
Accepted
How to pre-populate fields when creating a new record?
In lightning: you can do that using Set Predefined Field Values for Quick Action Fields. Here you predefine values for the new record created in quick action attributes and thus they gets ...
7
votes
Accepted
Name field type change for custom objects which are already used in a managed package showing error
When you create a package using 1GP(First generation) where one uses packaging org to create a package (instead of the local source code), certain attributes are Locked once the package is Managed-...
6
votes
What is the logic for the automatic creation and update of "standard" report types for custom objects?
Based on some light reverse engineering.
The "standard" report types are created whenever the enable reports option is checked on a custom object, or a master detail relationship to the reportable ...
6
votes
Accepted
Is it possible to create search layouts in a custom Object?
The reason that there are only 4 search layouts for a searchable custom object is that you have not created a Tab for it, which means a Tab and List View search layout have not been created yet.
I ...
6
votes
Accepted
Retrieve parent values from getPopulatedFieldsAsMap?
Contact__r looks like it's an object. You can get the object by doing this:
Contact cnt = (Contact)fieldsPopulated.get('Contact__r');
system.debug('Email: ' + cnt.Email);
system.debug('Name : ' + cnt....
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
custom-object × 1506apex × 385
visualforce × 235
custom-field × 180
trigger × 108
soql × 88
lookup × 74
relationships × 61
standard-objects × 61
custom-button × 60
managed-package × 56
related-list × 43
page-layout × 40
master-detail × 40
reporting × 38
formula-field × 32
picklist × 28
formula × 27
lightning × 26
permissions × 26
record × 26
object × 25
visual-workflow × 24
administration × 24
customsetting × 24