Date post: | 26-May-2015 |
Category: |
Technology |
Upload: | salesforce-developers |
View: | 388 times |
Download: | 2 times |
Coding techniques that keep your
admins happy
Writing configurable code in Salesforce
Roy Gilad, Israel Salesforce DUG, Leader
Conduit Mobile, CRM Solutions Manager
@RoyGilad
Roy Gilad
Israel Salesforce DUG Leader
CRM Solution Manager, Conduit Mobile
@RoyGilad
Coding techniques that keep your admins happy
What is this session
about?
DRY principle
Don’t Repeat Yourself:
“Every piece of knowledge must have a single, unambiguous,
authoritative representation within a system”
Coding techniques that keep your admins happy
In this presentation we will cover:
Custom Labels Field Sets Custom Settings
Custom Labels
Custom Labels
What is it?
Custom labels are custom text values that can be accessed from
anywhere:
Apex classes
Visualforce pages
Formulas
Validation rules
Custom Labels
Why should we use it?
Text to be maintained by a system administrators.
DRY: Reuse and consistency throughout the organization.
Code readability.
Multi-lingual support.
Custom Labels
Where can we find them?
Setup-> Build -> Create -> Custom Labels
Custom Labels
Demo
Custom Labels
Where should we use it?
Text in pages
Error messages in triggers
When you have multi-lingual org – A MUST!
Place-holder for repeated string in your code.
Custom Labels
How to use them?
Apex:
System.Label.Label_name
Visualforce:
{!$Label. Label_name}
Formula and validations:
$Label. Label_name
Field Sets
Field Sets
What is it?
Set of fields in an object that can be used dynamically in
Apex and in Visualforce pages.
Field sets are a powerful tool when you have a number of
fields used in the same operation, or in the same context.
Field Sets
Why should we use it?
Pages and integrations can be controlled by a system administrators.
DRY: Reuse and consistency throughout the organization.
Code readability.
Field Sets
Where can we find them?
Can be defined for any object:
• In standard objects it can be found under the object name:
• In custom objects it can be found as a related list in the object:
Field Sets
Demo
Field Sets
Where should we use them?
Visualforce pages and controllers.
Fields that are sometimes presented and updated together.
Field Sets
How to use them?
Visualforce pages:
• {!$ObjectType.Account.FieldSets.FieldSetName}
Apex:
• SObjectType.Account.FieldSets. FieldSetName.getFields()
Custom Settings
Custom Settings
What is it?
Similar to custom objects.
Enable developers to create custom sets of data.
Enable to create and associate custom data for an
organization, profile, or specific user.
Custom Settings
Why should we use it?
Access dictionary tables without querying.
Can provide Profile-specific and User-specific tables.
Custom Settings
Where can we find them?
Setup -> Build -> Develop -> Custom Settings
Custom Settings
Demo
Custom Settings
Demo
Custom Settings
Demo
Custom Settings
How do I use them?
Apex
List Custom Setting:
Hierarchy:
CustomSettingsName__c.getInstance(UserId \
ProfileId);
Summary
In this presentation we covered:
Custom Labels Field Sets Custom Settings
Roy Gilad
Israel DUG Leader,
@RoyGilad
Code is available for download at:
https://gist.github.com/RoyGilad
Presentation is available at:
http://www.slideshare.net/RoyGilad/salesforce-coding-
techniques-that-keep-your-admins-happy-df13