31
Coding techniques that keep your admins happy Writing configurable code in Salesforce Roy Gilad, Israel Salesforce DUG, Leader Conduit Mobile, CRM Solutions Manager @RoyGilad

Coding Techniques That Keep Your Admins Happy

Embed Size (px)

DESCRIPTION

Do you want to spend more time developing new and exciting features, and less time maintaining existing code when a field is added or an error message needs to change? Then keep yourself and your Administrator happy by coding to anticipate these changes using Custom Settings, Field Sets, and Labels. Join us as we show examples of these techniques and how they allow you to code so that your features can be easily configured.

Citation preview

Page 1: Coding Techniques That Keep Your Admins Happy

Coding techniques that keep your

admins happy

Writing configurable code in Salesforce

Roy Gilad, Israel Salesforce DUG, Leader

Conduit Mobile, CRM Solutions Manager

@RoyGilad

Page 2: Coding Techniques That Keep Your Admins Happy

Roy Gilad

Israel Salesforce DUG Leader

CRM Solution Manager, Conduit Mobile

@RoyGilad

Page 3: Coding Techniques That Keep Your Admins Happy

Coding techniques that keep your admins happy

What is this session

about?

Page 4: Coding Techniques That Keep Your Admins Happy

DRY principle

Don’t Repeat Yourself:

“Every piece of knowledge must have a single, unambiguous,

authoritative representation within a system”

Page 5: Coding Techniques That Keep Your Admins Happy

Coding techniques that keep your admins happy

In this presentation we will cover:

Custom Labels Field Sets Custom Settings

Page 6: Coding Techniques That Keep Your Admins Happy

Custom Labels

Page 7: Coding Techniques That Keep Your Admins Happy

Custom Labels

What is it?

Custom labels are custom text values that can be accessed from

anywhere:

Apex classes

Visualforce pages

Formulas

Validation rules

Page 8: Coding Techniques That Keep Your Admins Happy

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.

Page 9: Coding Techniques That Keep Your Admins Happy

Custom Labels

Where can we find them?

Setup-> Build -> Create -> Custom Labels

Page 10: Coding Techniques That Keep Your Admins Happy

Custom Labels

Demo

Page 11: Coding Techniques That Keep Your Admins Happy

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.

Page 12: Coding Techniques That Keep Your Admins Happy

Custom Labels

How to use them?

Apex:

System.Label.Label_name

Visualforce:

{!$Label. Label_name}

Formula and validations:

$Label. Label_name

Page 13: Coding Techniques That Keep Your Admins Happy

Field Sets

Page 14: Coding Techniques That Keep Your Admins Happy

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.

Page 15: Coding Techniques That Keep Your Admins Happy

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.

Page 16: Coding Techniques That Keep Your Admins Happy

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:

Page 17: Coding Techniques That Keep Your Admins Happy

Field Sets

Demo

Page 18: Coding Techniques That Keep Your Admins Happy

Field Sets

Where should we use them?

Visualforce pages and controllers.

Fields that are sometimes presented and updated together.

Page 19: Coding Techniques That Keep Your Admins Happy

Field Sets

How to use them?

Visualforce pages:

• {!$ObjectType.Account.FieldSets.FieldSetName}

Apex:

• SObjectType.Account.FieldSets. FieldSetName.getFields()

Page 20: Coding Techniques That Keep Your Admins Happy

Custom Settings

Page 21: Coding Techniques That Keep Your Admins Happy

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.

Page 22: Coding Techniques That Keep Your Admins Happy

Custom Settings

Why should we use it?

Access dictionary tables without querying.

Can provide Profile-specific and User-specific tables.

Page 23: Coding Techniques That Keep Your Admins Happy

Custom Settings

Where can we find them?

Setup -> Build -> Develop -> Custom Settings

Page 24: Coding Techniques That Keep Your Admins Happy

Custom Settings

Demo

Page 25: Coding Techniques That Keep Your Admins Happy

Custom Settings

Demo

Page 26: Coding Techniques That Keep Your Admins Happy

Custom Settings

Demo

Page 27: Coding Techniques That Keep Your Admins Happy

Custom Settings

How do I use them?

Apex

List Custom Setting:

Hierarchy:

CustomSettingsName__c.getInstance(UserId \

ProfileId);

Page 28: Coding Techniques That Keep Your Admins Happy

Summary

In this presentation we covered:

Custom Labels Field Sets Custom Settings

Page 29: Coding Techniques That Keep Your Admins Happy

Roy Gilad

Israel DUG Leader,

@RoyGilad

Page 30: Coding Techniques That Keep Your Admins Happy

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

Page 31: Coding Techniques That Keep Your Admins Happy