Pages

Tuesday, December 31, 2013

Chatter in Communities

Salesforce Communities is add-on feature for Salesforce user to connect directly with their resellers, distributors, and partners. Salesforce Communities generally available on Summer '13 release, early it is called Salesforce Partner Portal, but out of the box Communities have more features.

One of the most important Communities feature (compare to Portal) is availability of Chatter, where Salesforce user can collaborate directly with their Partner user directly via Chatter.

If you just setup Chatter in Communities and found that Communities user cannot see Salesforce internal user in Chatter, this is because security issue related to user sharing. There are few ways to enable this:

1. Sharing Setting
By default Organization-Wide Defaults for User object for Default External Access is Private, this is why partner user will not able to see internal user. If you change this to Public Read Only, this will allow all partner user in any communities to see all internal users.


2. User Sharing Rules
Create new sharing rule for Portal user to have read-only access to internal user. You can determine which portal roles (and subordinates) able to see which internal user or external user, by Role or Public Group

3. Manual Sharing
This process to manually share each users visible to which Partner role. Go to User detail page and click Sharing button, then specify Partner users (by Role or Public Group or All) able to see that particular user. In screenshot below, Steve is the only user shared to Partner using manual sharing.

Note: if you do not see User object Sharing Setting or Sharing button in User detail:
  • Make sure you have setup Communities, from: Setup - Customize - Communities - Settings
  • Contact Salesforce support to enable it

Reference:


Sunday, December 29, 2013

Salesforce: Dashboard with four-column table

Table is one of the component type available for dashboard. By default, tables show only two columns of data, but you can modify it up to 4 columns of data.

You can also personalize the table and show users’ Chatter photos as long as the table doesn’t have more than 20 rows.

Here are few items to note in customizing table columns:
  1. Make sure the source report is in matrix or summary format 
  2. Make sure the source report contains a chart
  3. Fields available to use in the table depends on the fields picked in the chart of source report 
  4. The chart in source report must contain groupings and at least one summary
  5. The first grouping in the report (not in chart) becomes the first column of the table.
  6. Use vertical bar chart in the report to make more fields available for the table.
  7. Click Customize table in table to add more columns (default only 2)

Sample 1



Sample 2



Limitations:
1. Customized tables will allow null values in the results. The Default two-column tables do not.
2. You can have the following combinations:
     2 grouped fields and 1 number
     2 grouped fields and 2 numbers
     1 grouped field and 2 numbers
     1 grouped field and 3 numbers. (Although we can do one grouping and three summaries, not all the summaries may be added. We cannot set different data type.)
     Not have 3 grouped fields and 1 number
3. Can’t sort by 2nd groupings


Reference:


Saturday, December 28, 2013

Salesforce: Lead Conversion Validation Rule

We blog on lead field conversion mapping sometimes back this year. In this blog, we would like to discuss how to run Validation Rules on Lead conversion process, this mean to block Lead conversion if not satisfy any rules. Few items to check:

1. Require Validation for Converted Leads
Earlier this option is called as Enforce Validation and Triggers from Lead Convert. Make sure this setting is enabled, otherwise Validation Rule on Lead conversion will be ignored. Go to Setup - Customize - Leads - Settings, enable Require Validation for Converted Leads. If you do not see this option, log a case with Salesforce support to get this option enable for you.

When this checkbox selected, it will check all validation rules in related objects of Lead conversion, including: Lead, Account, Contact and Opportunity (if Do not create a new opportunity upon conversion is not checked).



2. Set Validation Rule in Lead object
Use Case: company would like to stop lead conversion when Title is blank.
Here we go:
  • Create a validation rule in Lead using formula IsConverted
  • Make sure the rule is Active, many people forget to activate it and spend a lot of times before realize it is not active.


3. Set Validation Rule in target object
Target object here is Account, Contact and Opportunity
Use Case: company would like to block Account without website.
Although it is possible to create the rule in Lead, but if the validation rule in Account level, even you skip it in Lead object validation rule, validation rule in Account will take care for this.


Note:
When you have validation rule in both target, example: Account and Lead object with checking IsConverted, Account validation rule will kick-in before Lead validation rule with checking IsConverted field. This make sense because Salesforce will create / update Account before update Lead with IsConverted = True.


Reference:


Friday, December 27, 2013

Salesforce: NO Email Alert action for Task & Event workflow


THIS IS DELIVERED by SPRING '16 release


Normally, in Salesforce workflow, we can add action:
  • Create Task
  • Send Email Alert
  • Field Update
  • Send Outbound Message
But, if you realize (until release Summer '14 release) for workflow object Event and Task, there is NO Email Alert option for action.

Here is normal action for workflow:























And this screenshot on Event or Task, notice that "New Email Alert" is not there.

















This limitation has aware for quite long time, and someone has posted this in IdeaExchange, you are please to vote from here (currently it have 2670 points for this idea).


Workaround:

1. Create Workflow + New Task action 
This option may not be a nice, it will create another new task just to email user when Workflow on Task or Event triggered. You need to tick Notify Assignee in the task for Workflow.









2. Use AppExchange product - iTools Delegated Tasks Management
This is not a free product - https://appexchange.salesforce.com/listingDetail?listingId=a0N30000001gFJNEA2

3. Write Apex Trigger
Here a sample code for this.




Thursday, December 26, 2013

Update Salesforce using JavaScript AJAX Toolkit

For you who are not from developer background, don't be afraid with the title of this blog, this is not about how to write JavaScript blog. But, using a simple script provided with Ajax Toolkit, you can make use of it for your business needs in Salesforce area.

Use Case:
To change Account Type from Prospect to Customer via a button click, and Customer value itself maybe not a picklist in the account type.

Solution:
Create a custom button in Account object. Here we go:
  1. Navigate to Setup | Customize | Accounts | Buttons, Links, and Actions
  2. Click New Button or Link, select Detail Page Button in Display Type, and in Behavior select Execute JavaScript
  3. Paste script below
  4. Add custom button created to the Account page layout.
  5. Done - simple ?
The script:
 {!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}  
 var AccObj = new sforce.SObject("Account");  
 AccObj.Id = '{!Account.Id}';  
 AccObj.Type = 'Customer';  
 var result = sforce.connection.update([AccObj]);  
 location.reload(true);  




Further tweak, you also can differentiate Customer record type with Prospect record type, so in the script above, add one line to change Account Record Type with Customer Record Type Id, then assign different Page Layout for Customer.

Salesforce Last Login report using Date Value

Last month we wrote a blog of using LAST_WEEK ; LAST_N_DAYS:n ; N_DAYS_AGO:n for SOQL query, it is simple and very powerful to query Salesforce data dynamically.

The same we can implement for report and view. This blog will discuss using Relative Date Value, such as: Yesterday, Today, Tomorrow, This Week, Last Week, etc (for complete value, refer to this Salesforce documentation) in report and how to choose date value to use. We'll use Last n Months versus Last n Days for sample.

Use Case:
VP of IT would like to understand users not login to Salesforce in last 60 days.

Solution:
Using Salesforce report, we can easily create a report, by selecting Users report type (make sure you have admin privileges).




















Add a filter in the report Last Login not equal to LAST 60 DAYS and done. This report will show all users never login + users not login within last 60 days.

If you tweak the filter to Last Login not equal to LAST 2 MONTHS, surprisingly you will get very different result. 

Let us analyze, example today is 26 Dec 2013:
  • Using "not equal to LAST 2 MONTHS", will show users never login + users last login = Dec '13, because last 2 months in this scenario is Oct '13 & Nov '13. 
  • Using "not equal to Last 60 DAYS", will return users never login + users login before 27 Oct '13.
Make sense? Hope this help.


ReferenceUnderstanding Relative Date Values for Filter Criteria


Wednesday, December 18, 2013

Can we sort Salesforce Activity History?

Can we sort Salesforce Activity History? Until Summer '14 release, users cannot sort related list manually (including Activity History), and admin also not able to change the default sort. Activity History is always sorted by Due Date (or ActivityDate in API name) in descending order. It will not consider the created date or modified date in the sort order.

Here is a clear example of Activity History with the same Due Date:



Then, we edit item 2 and 3, we change the Due Date for item 2 to 8/23 and item 3 to 8/25, it will be re-sort with Due Date desc.



Remember Due Date is just a date, no time stamp, so if you have multiple activity history created at the same date, it will not order by created or last modified date time

But, we have a workaround, here we go:

1. Create Custom Button in Task
Setup - Customize - Activities -  Task Buttons, Links, and Actions
Click "New Button or Link", then select Behavior, Content Source and URL as the screenshot below:

/007?id={!Account.Id}&rlid=RelatedHistoryList <-- this is for Account

2. Add Custom Button into Account or Contact or other object page layout
Edit the Layout, scroll to Related Lists and look for Activity History.
Click 'Related List Properties' icon, then click + in Buttons sections, add the button to the right panel

3. Save the Page Layout and Done.
User will see a new button added to 'Activity History' related list. When the user click the button, it will open a new page where the user will be able to sort by any fields.


In Winter '15 release, Salesforce introduce sorting Activity History by Last Modified Date in ascending order, but caused some inconsistency and this has been reverted the changes made in Winter 15.


Deploy Salesforce Profiles with Change Set

Is it possible to deploy Profile using Change Set?
As of now (Summer '16) release, you cannot deploy Profile as stand alone component in Change Set. But, you can include Profiles in the Change Set. What this mean? Components setting (such as: custom field, custom object, etc) related to Profile will be deployed correctly for that Profile, but bear in mind that it also will deploy profile setting for Administrative Permissions, General User Permissions, Login Hours, Login IP Ranges for the profiles.

My experience in deploying Profile with Change Set is still very challenging (even we know Salesforce is keep enhance it). As Profile is not a Change Set component, it will not allow you to upload just Profile. So, if you want to deploy Profile, the workaround is to add a component to the Change Set, such as: custom field or others, then include the profile in Profile Settings For Included Components.



Below settings in Profile need be configure manually in target organization after change set deployed, if the corresponding components are not deployed in the same change set, example: you have a custom object called Invoice and profile called Sales, let's say Sales profile have Read, Create, Edit access to Invoice in source org., but if Sales profile is not included in the change set, Sales profile users will have no access to the Invoice object.
  • Standard Object Permissions
  • Custom Object Permissions
  • Field-Level Security
  • Tab Settings
  • Standard Object Layouts
  • Custom Object Layouts
  • Custom App Settings
  • Connected App Access
  • Record Type Settings
  • Apex Class Access
  • Visualforce Page Access

Following items will always deployed properly (overwrite target profile) in Profile when you include it, because it do not depend on other components:
  • Administrative Permissions
  • General User Permissions
  • Login Hours
  • Login IP Ranges

Profile not exist in target organization will be create, while existing profile will be overwritten (if the related components is in the change set). If you have a profile has been deleted in target instance, and you deploy Change Set with the same Profile name, deleted profile will be restored with all permissions before it is deleted.


Reference:

Tuesday, December 17, 2013

Salesforce: Attachments roll-up to the related Account

Do you realize that attachments on a Task or Event that is related to an Account, Contact, or Opportunity, will roll-up to appear in the Notes & Attachments related list on the Account record.

See this screenshot:

  • First attachment: related to a task in Opportunity linked to Account
  • Second attachment: related directly to Account
  • Third attachment: related to an email (which is a task) in Contact that linked to Account
  • Fourth attachment: related to Contact
  • Fifth attachment: related to an email (which is a task) linked to Account
But, they do not appear in in the Notes & Attachments for Contact or Opportunity, is this something weird?

And the worst, this is not customizeable and even to customize the related list for Notes & Attachments.

See this document related to this in Salesforce knowledge.


Thursday, December 12, 2013

Salesforce: Close Case in one click

To close a Case in Salesforce, user need to have Edit permission on Case object. By default, when a user click Close Case button, user will be bring into a new page to enter information needed before close the case. Admin can set mandatory fields at the Close Case page, from Setup - Customize - Case - Page Layout and look for Case Close Page Layouts.

But, can we make this simple? Meaning just click a button to close an open case without have to open a new page. Yes, by using custom button. Here we go:
  1. Setup - Customize - CasesButtons, Links, and Actions
  2. Click New Button or Link, enter Label and Name, select Detail Page Button in Display Type and Behavior select Execute JavaScript
  3. Paste JavaScript script below
  4. Add custom button created to the page layout and remove default Close Case button, you can have multiple page layout with different button based on user profile and Case record type.
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var caseObj = new sforce.SObject("Case");
caseObj.Id = '{!Case.Id}';
if ({!NOT(Case.IsClosed)}){
   caseObj.Status = 'Closed';
   var result = sforce.connection.update([caseObj]);
   if (result[0].success=='false') {
      alert(result[0].errors.message);
   } else {
      location.reload(true);
   }
}

Another option is to enable Closed value available in Case Status. By default, this value will be not available when user Create or Edit the Case, but we can enable it. Here we go: Setup - Customize - CasesSupport Settings, enable Show Closed Statuses in Case Status FieldThis will make Closed status available when user create or edit Case, user also will not bring into Case Close page any more.

In the same Case Support Setting page, admin also can hide Save & Close button by enable Hide Save & Close Button and Cls Links.


How about if I want to limit only certain profiles can close case?
Easy... create validation rule with this formula, sample:
RecordType.Name = 'CSD Case' && ISCHANGED(IsClosed) 


Read this document for more information on Closing Cases.


Friday, November 29, 2013

Salesforce: Modify default View in Object Tab

By default, when user click an object tab in Salesforce, example: Account tab, user will be presented with latest View selected by login user, example in screenshot below, it show "My Accounts" view, this mean, user select "My Accounts" before open an Account or click anywhere else. After View is Recent Accounts list.

Note: list of accounts when user click this Account tab is NOT "My Accounts" view, but it is Recent Accounts, until user click Go! button next to View name or select another View.


But, can we modify the default view when user click the tab? 

YES, using Visualforce page. Don't be afraid, you not really need to understand the whole Visualforce page script and Apex code, just copy from script below :) 

1. Always show a View
You can start create visualforce page from Setup - Develop - Pages, click New button, enter the label and name, then copy and paste script below
<apex:page>
    <apex:enhancedList listId="00B500000063yvG" height="600" customizable="true" rowsPerPage="10"/>
</apex:page>

Explanation:
  • listId : the Salesforce object for which views are displayed. This value is required if type is not specified. From above example: you can grab this View Id from URL when open a View, sample: https://na3.salesforce.com/001?fcf=00B500000063yvG this is always 15 characters
  • height : an integer value that specifies the height of the list in pixels. This value is required.
  • customizable : a Boolean value that specifies whether the list can be customized by the current user. If not specified, the default value is true. If this attribute is set to false, the current user will not be able to edit the list definition or change the list name, filter criteria, columns displayed, column order, or visibility, however, the current user's personal preferences can still be set, such as column width or sort order. If this attribute is set to true, user will see Edit | Delete | Create New View links. 
  • rowsPerPage : an integer value that specifies the number of rows per page. Possible values are 10, 25, 50, 100, 200. Note: If you set the value for greater than 100, a message is automatically displayed to the user, warning of the potential for performance degradation.

2. Always show "Recently Viewed Objects"
<apex:page showHeader="true" tabstyle="Opportunity"> 
    <apex:ListViews type="Opportunity" /> 
</apex:page>




Okay, so we can customize the tab using simple Visualforce page, next question, how to put it on? Two option:

1. Overwrite existing standard tab
  • Setup - Account (for Account object) - Buttons, Links, and Actions
  • Look for Accounts Tab (just change the object name for other object)
  • Click Edit link 
  • Select Visualforce Page option then page you create above
  • Save
To note: once you overwrite the tab with visualforce, default Force.com Quick Access Menu at the middle right of the page of View page will be no longer available.

2. Create new tab
  • Setup - Create - Tabs
  • Go to Visualforce Tabs 
  • Click New button
  • Select Visualforce page you create above
  • Follow the wizard and Save

Loop back: how to modify columns in Recent Object view?

Referenceapex:enhancedList


Tuesday, November 26, 2013

Salesforce: Notes and Attachments

Notes and Attachments is not a new thing in Salesforce. I also do not see any enhancements in last few Salesforce release. But, for some users, Notes and Attachments still a nice feature and frequently used.

Here a few facts on Notes and Attachments good to remember:
  1. It is not possible to report on the Notes and Attachments related list.
  2. The Notes & Attachments can be exported directly via the API.
  3. It is possible to access your Notes & Attachments data by requesting a full data export of your organization's data. 
  4. The only way to get the attachment on a Salesforce email to Attachment is to download the attachment to your local machine, then manually added as an Attachment from the local machine location.
  5. Notes and attachments marked as Private via the Private checkbox are accessible only to the person who attached them, Administrators and users with View All Data permission.
  6. You must have “Read/Write” access to parent record to be able to add Notes or Attachments to the record.
  7. You also need to have “Read/Write” access permission to parent record to be able to edit or delete Notes or Attachments.
  8. You can write Apex trigger for Notes & Attachments using Force.IDE
Special thanks to Jason Lawrence for the input of Feed Attachment, so if you attach File to Chatter Feed in an Account or Opportunity, it will show as well in Notes & Attachments as Feed Attachment.



Have a nice day!

Salesforce: Freeze API

Six months back, I wrote this blog to disable user login to SFDC temporary, maybe for major internal release.

In Winter '14 release, Salesforce introduce Freeze user feature. Administrator can easily freeze user, so he/she will not able to login to Salesforce temporary. But, if you have 500 users to freeze, it is not a nice job to open each user and click Freeze button.

Luckily, Salesforce provide API for this. It is a field called IsFrozen, located in a new object, called UserLogin. You only can see this object using API version 29.0 and above, so if you use Data Loader, make sure it is version 29.0 and above. You can query and update this object, but not create and delete as it will sync to User object.

Screenshot from Data Loader














SOQL to this object using Developer Workbench
SELECT Id, IsFrozen, IsPasswordLocked, LastModifiedById, LastModifiedDate, UserId FROM UserLogin















Monday, November 25, 2013

Salesforce SOQL query LAST_WEEK ; LAST_N_DAYS:n ; N_DAYS_AGO:n


LAST_WEEK
Using criteria LAST_WEEK in SOQL will return all records where the date starts from 12:00:00 AM (user Local Time Zone) on the first day of the week before the most recent first day of the week and continues for seven full days. The first day of the week is determined by your locale.
For example, my user locale setting is English (United States) and today = Sat, 23 Nov 2013, I run the query below:
SELECT Id, Name, CreatedDate FROM Account WHERE CreatedDate = LAST_WEEK ORDER BY CreatedDate DESC
this query will return accounts created between 10-16 Nov 2013, because for Locale is US English, a week runs Sunday to Saturday, whereas with UK English, a week spans Monday to Sunday.

SELECT Id, Name, CreatedDate FROM Account WHERE CreatedDate < LAST_WEEK ORDER BY CreatedDate DESC
this query will return accounts created before 10 Nov 2013.

LAST_N_DAYS:7
Using LAST_N_DAYS:7 in SOQL will return all records where the date starts from 12:00:00 AM (user Local Time Zone) of the current day and continues for the last 7 days.
SELECT Id, Name, CreatedDate FROM Account WHERE CreatedDate = LAST_N_DAYS:7 ORDER BY CreatedDate DESC
If today is Friday, 22 Nov 2013, using LAST_N_DAYS:7 will return the account created between 16 - 22 Nov 2013, while LAST_WEEK will return the account between 10 - 16 Nov 2013.

N_DAYS_AGO:7
Using N_DAYS_AGO:7 in SOQL will return all records where the date starts from 12:00:00 AM (user Local Time Zone) on the day 7 days before the current day and continues for 24 hours. (The range does not include today.)
SELECT Id, Name, CreatedDate FROM Account WHERE CreatedDate = N_DAYS_AGO:7 ORDER BY CreatedDate DESC
If today is Monday, 25 Nov 2013, using N_DAYS_AGO:7 will return account only created on 18 Nov 2013. 


Please note all Date field returns in the SOQL query will be in GMT format, for example, 2013-11-18T08:05:21.000Z, so you need to convert it as needed.


Sunday, November 24, 2013

How to show only top X values in Salesforce Dashboard ?

By default, Salesforce Dashboard will show all values in Vertical Bar Chart, Horizontal Bar Chart, Line Chart, Pie Chart, Donut Chart, Funnel Chart, Scatter Chart, and Table component. Component below show All Chatters Group with number of members for each Group.

But, how to show just top 3 group with most members? It is easy in Salesforce:
  1. Edit the dashboard
  2. Click 'Edit Attributes' icon
  3. Go to 'Formatting' tab
  4. Look for Maximum Values Displayed and enter 3
  5. Make sure select Sort by Value Descending
  6. Once you move your mouse cursor out of that field, you will notice preview at the right change to 3
  7. Click OK 
  8. Done

You can use the same way to show top 10 Sales Rep, or top 5 area with minimum claim, etc.



Friday, November 22, 2013

Salesforce: Lead Conversion Field Mapping

When you convert a Lead, standard Lead fields automatically converted into Account, Contact, and Opportunity - as mapping below:
Lead FieldMaps to
AddressAccount: Billing Address
Contact: Mailing Address
Annual RevenueAccount: Annual Revenue
CampaignOpportunity: Primary Campaign Source
If the lead has multiple associated campaigns, the most recently associated campaign is inserted into the opportunity regardless of whether the user has sharing access to it.
CompanyAccount: Account Name
Contact: Account
Opportunity: Account Name
Opportunity: Opportunity Name
Company Name (Local)Account: Account Name (Local)
DescriptionContact: Description
Do Not CallContact: Do Not Call
This field is not updated for leads converted to existing contacts.
EmailContact: Email
Email Opt OutContact: Email Opt Out
This field is not updated for leads converted to existing contacts.
FaxAccount: Fax
Contact: Fax
Fax Opt OutContact: Fax Opt Out
First NameContact: First Name
First Name (Local)Contact: First Name (Local)
IndustryAccount: Industry
Last NameContact: Last Name
Last Name (Local)Contact: Last Name (Local)
Lead OwnerAccount: Owner
Contact: Owner
Opportunity: Owner
Lead SourceAccount: Lead Source
Contact: Lead Source
Opportunity: Lead Source
Person Account: Lead Source
MobileContact: Mobile
No. of EmployeesAccount: Employees
Partner AccountOpportunity: Partner Account
This field is not updated for leads converted to existing opportunities.
PhoneAccount: Phone
Contact: Phone
RatingAccount: Rating
TitleContact: Title
WebsiteAccount: Website

As you see from above mapping, Lead Source is only mapped to Contact and Opportunity, not to Account Source, but if you need it, here is the workaround by using custom Account Source field - Map Lead Source field on Lead object to Account Source field on Account object during lead conversion. If you aware the default Account Source picklist values are sync with Lead Source, so you may need to make sure this custom Account Source picklist values need to manually sync. At some points, Lead Source to Account Source mapping has been automated by Salesforce.

If you are not using custom fiscal years, the Close Date of the opportunity created is automatically set to the last day of the current fiscal quarter.

If you are using custom fiscal years, the Close Date is the last day of the current fiscal period. If you are using custom fiscal years and a fiscal year has not been defined for the current date, the Close Date is the end of the current calendar quarter.

Custom lead fields only can be converted into custom account, contact, and opportunity fields as specified by the system administrator (not map to the standard field). To specify the mapping for custom lead fields:
  1. From Setup, click Customize | Leads | Fields | Map Lead Fields.
  2. For each custom lead field, choose a custom account, contact, or opportunity field into which you want the information inserted when you convert a lead.
  3. Click Save.
It's best practice to map custom lead fields to other custom fields with the same field type, but here some exceptions and tightened:
  • You can only map Number to Number, Currency to Currency, and Percent to Percent field with the exact same field length and same decimal point.
  • The lookup field only can be mapped to other lookup fields with the same lookup object.
  • You can map from Text and Text Area to Picklist, even the text value does not exist in picklist value.
  • You can map from Picklist to Text, Text Area, and Long Text Area, but if the picklist value is longer than the length of the text field, it will throw system error upon conversion process - System.DmlException: Insert failed. First exception on row 0; first error: STRING_TOO_LONG
  • You can map from Auto NumberText and Text Area to Text, Text Area, and Long Text Area field.
  • You can map from a Formula field in lead, it treats as a normal field depends on the formula return type.
  • You cannot map a Formula field into account, contact, and opportunity.
  • Standard lead picklist fields that are blank are mapped to the default picklist values for the account, contact, and opportunity (remember to check default value if you are using Record Type for the target object).

Friday, November 15, 2013

New Salesforce.com Certified Logos

Just one week before Dreamforce '13, Salesforce introduce new logos for Salesforce.com Certified Professional.





This is Salesforce.com certificates currently I hold:




Monday, November 11, 2013

Salesforce Custom Setting

Although Custom Setting is similar with Custom Object, but they are very different and totally for different usage. Custom object used to store all data within Salesforce for any transactions, it works similar with standard object, such as: Account, Contact, Opportunity, etc and you can create custom tab for that object.

While Custom Setting used to store application configurations, such as: value based on each application type or user. You cannot put show custom setting value directly as a custom tab. But, to access custom setting data, you need to access it from: Formula fields, Validation rules, Workflow rules, Apex class, and API.

There are 2 type of custom setting: List and Hierarchy. Formula field, Validation rule and Workflow rule only can access Hierarchy type custom setting, while Apex and API can access both. Once you select the type, you will not able to change it.

If the custom setting is a list, you can add set of data. For example, if your application had a setting for country codes, each set might include the country's name and dialing code.

If the custom setting is a hierarchy, you can add data for the user, profile, or organization level. For example, you may want different values to display depending on whether a specific user login to system, or a specific profile, or for general users.

To access hierarchy Custom Setting from formula field, workflow rule or validation rule:
{!$Setup.CustomSettingName__c.CustomFieldName__c}

Use case: all users have to select Account Active status, except System Administrator.

Here is the step to use Custom Setting in Validation Rule:
1. Create Custom Setting:  Setup | Develop | Custom Settings
2. Create Fields in Custom Settings

3. Manage Custom Settings
Enter Default Organization Level Value, you can skip the value for User or Profile level.

4. Modify Validation Rule
($User.ProfileId <> $Setup.Rules_Id__c.Exception_Id__c) && ISBLANK(TEXT(Active__c))

Checkout this blog for step-by-step to configure Custom Setting.


To access Custom Setting from API:
SELECT Id, Name, Exception_Id__c, Name__c FROM Rules_Id__c
This is very similar with SOQL query to custom object, isn't it?


Limitation of Custom Setting:
  • Maximum total data of 10 MB, but if you have less than 10 license users, multiply 1 MB with number of users
  • 300 fields per custom setting.
  • Can’t share a custom setting record.
  • No owner assigned for each custom setting record
  • Each custom setting counts against the total number of custom objects available for your organization.

You can access Custom Setting field through SOAP API, run SOQL to get the values, and it can be deployed using Change Set.

To deploy custom setting data/value, you can use Data Loader, see this blog.


Reference:



Page-level ad