Pages

Thursday, July 25, 2013

Salesforce: cannot select a picklist value, why???

When user create new record, user cannot select a value from Picklist field, what is the caused?

There are few caused:

1. Record Type
If the object have record type, only one picklist value selected for that record type.
Analysis: user still be able to select '--None--' or a picklist value.

2. Read-Only in Page Layout
If in page payout, the picklist value is mark as Read-Only,
Analysis:
  • if Default value for that field in field level (object without record type) or Default value for that field in record type is '--None--', user will not see anything value in that field.
  • if a value is selected in Default value for that field in field level (object without record type) or Default value for that field in record type, user will see the default value in page layout without option to change it.
User with profile have permission "Edit Read Only Fields" will able to select available values.

3. Read-Only in Field-Level Security
This is almost the same with point (2) above, the difference is only determined by user profile rather than to all users.
Analysis:
  • if Default value for that field in field level (object without record type) or Default value for that field in record type is '--None--', user will not see anything in the page layout.
  • if a value is selected in Default value for that field in field level (object without record type) or Default value for that field in record type, user will see the default value in page layout without option to change it.
User with profile have permission "Edit Read Only Fields" will able to select available values.

Friday, July 19, 2013

Salesforce Opportunity History (Stage History)

If we enable History tracking for an object in Salesforce, Salesforce will automatically create a new object with API name suffix History, example: AccountHistory, ContactHistory, Custom_Object__History. But, it is different for Opportunity, the object API is called OpportunityFieldHistory, please not to confuse with OpportunityHistory.

So what is Opportunity History?
The Opportunity History or Stage History tracks the changes in opportunity based fields below. Anytime you change those fields, a new entry is added to the list with the user who made the change and the time stamp, and it also records the value of the fields after changed:
  • Stage
  • Amount
  • Probability (%)
  • Close Date 

You can find this values in:

1. Opportunity page layout
In Opportunity page layout, find the related list called Stage History. This related list is not customize-able.


2. Report
In the report, you can create a report with report type = Opportunity History


In the screenshot below, you will see the changes with Last Modified is the date change happened and the user who change in Last Modified By


You also can filter the report to show only when Stage is changed or filter with Forecast Changed From/To values, see this screenshot:


3. API
The API object name is OpportunityHistory, you can query this object, but not update, delete or create manually.


Thursday, July 18, 2013

Salesforce Field Dependencies deployment

Field Dependencies is one of basic, simple, but very powerful feature from Salesforce.com and has been release long time back. This blog is not about on how to create field dependency, but more on field dependency deployment.

What is deploy mean here? It is deploy from one instance to another instance in Salesforce. Then, next question, Why we need to deploy such a simple thing?
Cannot we just create or update in Production instance directly? - Yes, of course you can.
But, when you have a big list of dependency field and by standard best-practice, you should:
- change it in sandbox instance
- get user to test it in sandbox instance and approve
- deploy it to production

Okay, now we are clear why need to "deploy" such a simple thing like field dependency.

Use case: a global company present in many countries and cities around the world. Both country and city is picklist value, city must be valid only for a country, this is pretty basic and field dependency is best solution available city value is dependent on country selection. Since company is growth very rapidly, admin need keep to update city within country, or even remove city which no longer valid.

Deployment

After user test and approve in sandbox, here are steps to deploy using Change Sets:
  • Go to Setup - Deploy - Outbound Change Sets
  • Create new Change Set, type a Name and Description, always add description on what will be add into this change set
  • In the Change Set Components, look for Custom Field
  • Find and add Dependent Field (not Controlling field, unless it is needed)
  • Upload to Production instance
  • Switch  to Production instance, Setup - Deploy - Inbound Change Sets and find the new Change Set name
  • You may Validate before Deploy to make sure everything is good
  • Done
I believe you can do the same using Force.com IDE to deploy, similar result using Change Set.

Notes: if you have records with old dependent field which no longer there, the old value will remind there until you update it manually, so don't afraid this exercise will update all existing data.

If you have Record Type on that object, you need to add the new values in Picklists Available for Editing, otherwise the new picklist values will not shown in page layout, although it is added in Field Dependency.

Sunday, July 7, 2013

Salesforce image formula field

What is the most easy way to get user attention in a Salesforce page? One of the best option is to use image. You can build Visualforce page (and with Apex code) to display images in Salesforce page. But, hold on, Visualforce is not the only way to display image. You can use IMAGE() in a formula field, this is much more easier and faster if possible.

See below use cases:

1. Show customer support status
If a customer purchase support product and still active, show active sign, if no longer active, show expired sign and if not purchase any support, show cross sign.

For this case, you need to upload 3 images into a document. I'll not discuss on how to upload images to a document folder. But, you can look from think link, please note the max size for document only 5 MB.
After all images uploaded to a folder in document, follow this steps:
  • Create a New formula field
  • Name the field “Support Status”
  • Choose Text as the formula field type
  • Copy and paste following formula 
IF (NOT ISNULL(Support_Expiration_Date__c), IF (Support_Expiration_Date__c > Today(), IMAGE("/servlet/servlet.ImageServer?id=01550000000eCt0&oid=00D300000000SHq","Active"), IMAGE("/servlet/servlet.ImageServer?id=01550000000OD0h&oid=00D300000000SHq","Expired")), IMAGE("/servlet/servlet.ImageServer?id=01550000000dXsc&oid=00D300000000SHq","No Support"))

Basically, parameters for id = Image Id and oid = Organization Id, you can get the URL from document page. At the image field, right click and select "Open image in new tab" (for Google Chrome).
To use servlet.ImageServer make sure Externally Available Image is enabled, otherwise change the format to
/servlet/servlet.FileDownload?file=01550000000eiu6


2. Show customer category depend on opportunity Closed Won amount
  • Create Roll-Up Summary field in Account
  • Name the field "Closed Won Amount"
  • Select "Opportunities" in object to summarized, 
  • Roll-Up Type = Amount; Field to Aggregate = Amount; Filter Criteria only record Won equals to True. Done for Roll-Up Summary field
  • Create a New Formula field in Account
  • Name the field “Customer Category”
  • Choose Text as the formula field type
  • Copy and paste following formula 
IF ( Closed_Won_amount__c > 0, IMAGE("/servlet/servlet.FileDownload?file=01550000000eiu6", "money", 18,18), NULL)
+ " " +
IF ( Closed_Won_amount__c > 10000, IMAGE("/servlet/servlet.FileDownload?file=01550000000eiu6", "money", 18,18), NULL)
+ " " +
IF ( Closed_Won_amount__c > 25000, IMAGE("/servlet/servlet.FileDownload?file=01550000000eiu6", "money", 18,18), NULL)
+ " " +
IF ( Closed_Won_amount__c > 50000, IMAGE("/servlet/servlet.FileDownload?file=01550000000eiu6", "money", 18,18), NULL)
+ " " +
IF ( Closed_Won_amount__c > 100000, IMAGE("/servlet/servlet.FileDownload?file=01550000000eiu6", "money", 18,18), NULL)


Here is the final layout in Account page layout:

Monday, July 1, 2013

Salesforce: Web-to-Lead hidden field

I wrote a blog last month on how to set Lead record type in a Web-to-Lead form, you can use hidden field, for example:
<input type=hidden name="recordType" id="recordType" value="01250000000HkoV">

We can use any field, include Lead custom field as hidden field using same format, but you need to change the name with the correct Field Id.

Format
<input type=hidden name="FieldId" value="any value">

Example
<input type=hidden name="00N30000000h9w3" value="From Website">

Field Id
How to get field id? Go the Setup menu - Customize - Leads - Fields, scroll down and look for the field and click the field name.










For screenshot above, we can easily know the field id for this field is 00N30000000h9w3