Pages

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 - Cases - Buttons, 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 - Cases - Support Settings, enable Show Closed Statuses in Case Status Field. This 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?

Reference: apex: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!

Page-level ad