Pages

Monday, January 7, 2013

Salesforce Opportunity Roll-Up

Roll-Up summary field is a nice feature in Salesforce to summary data from child record to parent within Master-Detail relationship object.

Although, Account and Opportunity is standard Salesforce object, but we can set Roll-Up summary for many purposes.

Date of last won deal
We can easily know and display when closed won opportunity in Account page layout without complex triggers.
Create roll-up summary field in Account with
- Summarized Object = Opportunity
- Field to Aggregate = Opportunity: Close Date
- Filter Criteria = Won EQUALS True
- Summary Type = MAX

Number of Opportunities
Display number of opportunities in Account page layout
Create roll-up summary field in Account with
- Summarized Object = Opportunity
- Filter Criteria =
- Summary Type = COUNT

Number of Won Opportunities
Display number of won opportunities in Account page layout
Create roll-up summary field in Account with
- Summarized Object = Opportunity
- Filter Criteria = Won EQUALS True
- Summary Type = COUNT

Total Amount of Won Opportunities
Display total amount of won opportunities in Account page layout
Create roll-up summary field in Account with
- Summarized Object = Opportunity
- Field to Aggregate = Opportunity: Amount
- Filter Criteria = Won EQUALS True
- Summary Type = SUM

Win Percentage
Display percentage of closed won opportunity for account
Create formula field with return type = Percent, with 2 decimal place
Formula = IF(Count_of_Opportunities__c > 0, Count_Won_Opportunities__c / Count_of_Opportunities__c,0)

For more information on Roll-Up Summary, click here for Salesforce documentation.

Sunday, January 6, 2013

Salesforce: Useful Formulas related to Date

Here are some useful formula related to date. In this sample, I have a custom field call Execution Time with data type = Date/Time

Find me Execution Date
Create a formula field with return type = Date --> Execution_Date__c
DATEVALUE(Execution_Time__c)


Find me last date of the month of Execution Date
Create a formula field with return type = Date
CASE( 
MONTH(Execution_Date__c), 
1, DATE( YEAR( Execution_Date__c ), 01, 31), 
2, DATE( YEAR( Execution_Date__c ), 02, IF( MOD( YEAR(Execution_Date__c), 4) = 0, 29, 28)), 
3, DATE( YEAR( Execution_Date__c ), 03, 31), 
4, DATE( YEAR( Execution_Date__c ), 04, 30), 
5, DATE( YEAR( Execution_Date__c ), 05, 31), 
6, DATE( YEAR( Execution_Date__c ), 06, 30), 
7, DATE( YEAR( Execution_Date__c ), 07, 31), 
8, DATE( YEAR( Execution_Date__c ), 08, 31), 
9, DATE( YEAR( Execution_Date__c ), 09, 30), 
10, DATE( YEAR( Execution_Date__c ), 10, 31), 
11, DATE( YEAR( Execution_Date__c ), 11, 30), 
12, DATE( YEAR( Execution_Date__c ), 12, 31), 
null 
)

This is another simplify formula and will get the same result
IF( 
MONTH( Execution_Date__c ) = 12, 
Date( YEAR( Execution_Date__c ), 12, 31 ), 
Date( YEAR( Execution_Date__c ), MONTH ( Execution_Date__c ) + 1, 1 ) - 1
)


Find me last date next month of Execution Date
Create a formula field with return type = Date
CASE( 
MONTH(Execution_Date__c), 
1, DATE( YEAR( Execution_Date__c ), 02, IF( MOD( YEAR(Execution_Date__c), 4) = 0, 29, 28)), 
2, DATE( YEAR( Execution_Date__c ), 03, 31), 
3, DATE( YEAR( Execution_Date__c ), 04, 30), 
4, DATE( YEAR( Execution_Date__c ), 05, 31), 
5, DATE( YEAR( Execution_Date__c ), 06, 30), 
6, DATE( YEAR( Execution_Date__c ), 07, 31), 
7, DATE( YEAR( Execution_Date__c ), 08, 31), 
8, DATE( YEAR( Execution_Date__c ), 09, 30), 
9, DATE( YEAR( Execution_Date__c ), 10, 31), 
10, DATE( YEAR( Execution_Date__c ), 11, 30), 
11, DATE( YEAR( Execution_Date__c ), 12, 31), 
12, DATE( YEAR( Execution_Date__c )+1, 01, 31),

null 
)



Find me calendar week of Execution Date
Create a formula field with return type = Number
CEILING(((DATEVALUE(Execution_Time__c) - DATE(YEAR(DATEVALUE(Execution_Time__c)), 1, 1) + 1) + MOD(DATE(YEAR(DATEVALUE(Execution_Time__c)), 1, 1) - DATE(1900, 1, 7), 7)) / 7) - 1 

Another option:
CEILING((DATEVALUE(Execution_Time__c) - DATE(YEAR(DATEVALUE(Execution_Time__c)), 1, 4) +1 ) / 7)

*** to confirm week is correct, use this website http://www.calendar-365.com
*** 1 Jan 1900 = Monday


Find me day of the week from Execution Date
Create a formula field with return type = Text
CASE( MOD( Date__c - DATE(1900, 1, 7), 7),
0, "Sunday",
1, "Monday",
2, "Tuesday",
3, "Wednesday",
4, "Thursday",
5, "Friday",
6, "Saturday",
"Error")
*** 7 Jan 1900 = Sunday


Find me the day of Execution Date
Create a formula field with return type = Number
DAY(Execution_Date__c)


Find me number of day between Request DateTime with Execution Date Time
Create a formula field with return type = Number
DATEVALUE(Execution_Time__c) - DATEVALUE(Request_Time__c)


Find me first date of the week of record Creation Date
Create a formula field with return type = Date
DATEVALUE(CreatedDate) - MOD(DATEVALUE(CreatedDate) - DATE(1900, 1, 7), 7)
This formula will return Sunday as the first date of the week.


Find me first date of the week of record Creation Date, with MONDAY as the first date of the week
Create a formula field with return type = Date
CASE( MOD( DATEVALUE(CreatedDate) - DATE(1900, 1, 7), 7), 0, 
DATEVALUE(CreatedDate) - MOD(DATEVALUE(CreatedDate) - DATE(1900, 1, 7), 7) - 6, 
DATEVALUE(CreatedDate) - MOD(DATEVALUE(CreatedDate) - DATE(1900, 1, 7), 7) + 1)
*** Case result 0 = Sunday


Reference


Last update: 20 Jun 2016


Tuesday, January 1, 2013

Salesforce delete record: 'Insufficient privileges' error

In some organisation, user allow to delete records, but sometimes user get error message 'Insufficient privileges' although Delete button exist. What's happening? Let us analyze:

1. User able to access the record
There are few scenario:
  • Organization-Wide Defaults sharing setting on that object is Public Read Only or Public Read/Write; or 
  • Sharing rule added based on record owner or criteria for Public Groups or Roles; or
  • User is the owner of the records; or
  • User in higher role hierarchy of record owner; or
  • User profile have "View all Data" or "Modify all Data" permission

2. User see Delete button
This is happened because:
  • Delete button is added in record page layout; and
  • User profile have permission to delete that object

3. Error 'Insufficient privileges' 
The ability to delete records in Salesforce is controlled by the role hierarchy. Setting a sharing model to "Public Read/Write" alone does not give users the right to delete others records. There are 2 scenarios in which a user can delete a record:

  • The user attempting to delete the record is a System Administrator.
  • The user attempting to delete the record is the owner, or higher on the role hierarchy than the record owner.
Any other user that attempts to delete a record will receive an "Insufficient Privilege" error message.

Those below you on the role hierarchy may have read/write privileges according to the sharing model rules, however, they may not delete information from those individuals above them in that hierarchy. 


For complete knowledge from Salesforce, click here



Monday, December 31, 2012

Salesforce Customer Community

You have technical question on Salesforce.com configuration? There are few place to ask questions:

1. Salesforce Customer Community
This is forum supported by Salesforce and answer by Salesforce user community global. Post your questions from http://success.salesforce.com/answers. Usually a 'hero' (like SteveMo, phiberoptik, etc) will answer your questions. But as this is a forum, don't expect your questions will always response. Try to post your questions as clear as possible.

This forum particularly only for Salesforce admin, if you are not admin, please check with your admin before post questions here.

2. Salesforce Support
Open a case from 'Help & Training' link next to your name in Salesforce.com top right corner. Click "Contact Support" and "Open a Case". You also can "Ask the Community" from this page, which will be redirect to the same Customer Community above.

If you do not purchase Premier support or using Unlimited Edition, please expect 2 business days response. For Premier support customer, response time is 2 hours.


As today is the last day of 2012, I would like to say "Happy Holiday and Happy New Year 2013, may the year of 2013 ahead bring all of us a better health, prosperous in love and live. GBU!"

Also, today I hit rank #5 for the first time in Salesforce Community Support.





















Using Salesforce Content and Chatter File to share file

Two months ago, I wrote a blog on how to publish image or document to public using Salesforce.com easily using Document. It works well, but Document have some limitation, very basic and do not have security:
- Cannot set password protection
- Cannot set expiration date
- Do not have visibility on view count, first and last file viewed
- Do not link to a record in Salesforce
- Do not have build-in preview
- Do not have version capability
- Maximum up to 5 MB of file size, more information here
But, document still a good option to sharing file internally with security of access implemented in Folder.

In this blog, I would like to share using Content Delivery and Chatter Files to share file with public.

Content Delivery

1. Enable Content Delivery.
Contact Salesforce support to activate Content Delivery (if it has not been activated), don't be afraid as this feature is free. To check if Content Delivery is activated, navigate to SetupCustomize  - Salesforce Files - SettingsContent Deliveries, if you see Content Deliveries menu here, your instance already has been activated with Content Delivery. Make sure Enable content deliveries is checked.


2. Add Content Delivery related list to the page layout, example to Account.

3. From object (in this sample Account) page layout, scroll to Content Deliveries related list added and click button Deliver Content.

4. Choose a file to upload and follow the wizard, you can rename delivery name, set notification, expiration date, and password. If your file is Microsoft Office file, you have more option for Delivery Method.


5. Done. You can pass the URL to your business partner securely and you know if when he open the file.

Using Content Delivery, you can upload file size up to 2 GB, compare this to Document which only 5 MB. For more information on setting Content Delivery, click this link


Chatter Files

Another option to publish file using Chatter File.

1. To share via Chatter File, you need to activate in Content Delivery as well, see points above to activate Content Delivery.

2. After Content Delivery activated, make sure Enable Creation of Content Deliveries for Chatter Files is checked.


3. Once Enable Creation of Content Deliveries for Chatter Files is checked, to allow user to share file via link, add permissions Create and Share Content Deliveries for Chatter Files in user profile to allow user to share file via URL.

4. Go to Files tab, upload file. You will see a new menu Share via link



5. Done. URL created will have the same format with Content Delivery link.

For more information on sharing Chatter files via link, click here


Few items to note using Content Delivery and Chatter Files
  1. Using Chatter File, you do not have option to download in PDF, enable password, enable expiration date, notification and timestamp when the file open.
  2. Although file uploaded via Content Delivery will be in Chatter Files, but you will not have "Share via Link" menu option.
  3. Both Content Delivery and Chatter File support up to 2 GB of file size limit.
  4. Both Content Delivery and Chatter File support file preview.
  5. Both Content Delivery and Chatter File allow you for upload new version. To upload new version for Content Delivery file, go to Content Detail Page in Chatter File.
  6. To delete file uploaded via Content Delivery, go to Content Detail Page in Chatter File.

Reference:



Wednesday, December 19, 2012

Cross-Object Workflow in Salesforce.com

With Spring '12 release, cross-object field update in workflow rules and approval processes is now support standard objects. Both custom-to-standard and limited standard-to-standard relationships are supported. This feature only available in Enterprise and Unlimited edition.

Only Master-Detail relationship support for cross-object workflow, so it is not for objects with Lookup relationship.

Here is a sample case of using Cross-Object workflow.
Master object: Customer__c
Child object: Order__c
Company would like to know how total amount and when latest order for each customer, use payment date instead of order date. Payment date will be blank when customer have not make payment.

Here we go:
1. Create a workflow in Order 
Evaluation Criteria : Evaluate the rule when a record is created, and every time it’s edited
Rule Criteria:
NOT ISBLANK( Payment_Date__c ) && 
( Payment_Date__c >= Customer__r.Payment_Date_hidden__c || 
ISBLANK( Customer__r.Payment_Date_hidden__c ))

Explanation:
- if Payment Date in order is blank, stop workflow
- if Payment Date in order is newer than stored Payment Date in customer, proceed workflow OR if stored
Payment Date in customer is blank



2. Create a field update action in Order
Update Payment Date in Customer
Select object = Order
Field to Update = Customer, the select field Payment Date
Formula Value = Payment_Date__c from Order



3. Create a Roll-Up Summary field in Customer for Total Amount
Create new Roll-Up Summary field from Customer object
Summarized Object = Orders
Select Roll-Up Type = SUM
Field to Aggregate = Amount
Filter Criteria = Payment Date NOT EQUAL TO blank


Last one, remember to Activate the workflow.

If you see in above process, workflow in Order will update field in the parent object Customer. So, it is cross-object workflow field-update.

The same solution you can use to update Account from Opportunity, example: if opportunity is Closed Won, automatically update Account Type to Customer.


For more information and standard objects supported, see this release document and find section Cross-Object Workflow. 

Page-level ad