Pages

Sunday, January 19, 2014

Mass deactivate Salesforce Validation Rule or Workflow Rule

As of now Winter '14 release, Salesforce do not have switch to mass turn OFF and ON Validation rules and Workflow rules. In some use case, we need to turn it off, such as in event of mass load data.

But, using some trick, we can make use of Custom Setting as a master switch. Custom Setting is mostly used by developer and not famous among Salesforce admin. I blog about custom setting sometime last year, read here.

Here is the step, let say we want to deactivate all Validation rule in Account:

1. Create Custom Setting
  • Setup - Develop - Custom Settings
  • Click 'New' button
  • Enter Label 'Master Validation', Object Name, Description and select Setting Type = Hierarchy
  • Save


2. Create Fields in Custom Settings 
  • Continue from step 1 above, in custom setting created 
  • Click 'New' button in Custom Fields related list
  • Select Checkbox field type
  • Enter field name and label 'Account Active'
  • Enter Description and Help Text as necessary, Default Value does not really mattered.
So, this is what we have now after add field.


3. Manage Custom Settings 
  • Click Manage button for that Custom Setting to set Default Organization Level Value
  • You should see all fields available 
  • Click Edit button and make sure 'Account Active' is checked
  • Save


4. Field Value for User or Profile (Optional)
You also can determine each user Profile value, users or profiles not added here will use Default Organization Level Value set in step 3 above.
  • Click New in Manage Custom Setting 
  • Select user or profile in the lookup window
  • Check active checkbox button
  • Tips: if you just need to deactivate validation rule only to a profile, example: only for System Administrator when he load data using Data Loader, you just need to add 1 profile here to deactivate the value and let the rest of profiles Active via Default Organization Level Value.


5. Modify Validation Rule
Add following formula '$Setup.Master_Validation__c.Account_Active__c' in Error Condition Formula.

6. Done


Summary:
  • Pro: Admin have full control to ON or OFF validation rule and workflow rule based on Object and Profile (or even User)
  • Cons: Each existing validation rule and workflow rule need to modify and add additional formula into the formula.

Friday, January 17, 2014

Salesforce: How to modify columns in Recent Object view?

Recent object view is one of the view, most viewed by all Salesforce users by default, because when a user click a tab, Recent object is the default view, unless you modify it. We discussed on how to modify default view in object Tab in previous blog.

So, how to modify the columns Recent Object when user click Object Tab?

1. Standard object (example: Account)
  • Go to Setup - Customize - Accounts - Search Layouts 
  • Click Edit link on Account Tab
  • Select fields to show for Recent Tab



2. Custom object
  • Go to Setup - Create - Objects 
  • Find the custom object and click the object name
  • Scroll down to Search Layouts 
  • Look for object name Tab and click Edit link
  • Select fields to show for Recent Tab

Note: this changes will affected to ALL users, so make sure to communicate with users and approval (based on your company policy)

Thursday, January 16, 2014

Salesforce: Accept Queue in Page Layout

A Queue can to support multiple object: Case, Lead and Custom object with list of users.

View
When a queue is created for an object, example Case, by default, a View will with the Queue name will be created in Case View. This View will filtered by owner of the Queue name. The View will be visible for All Internal Users.

Case assign to a queue will be shown in that View.

Accept Queue
By default, user in the Queue will see all Case owned by that Queue in the View. User would like to accept that Case just need to click Accept button in the View.

But, usually user need to go into the case detail before Accept the case, so it is not really user friendly if user have to go back to the View to Accept it. It would be nice and more efficient if user able to Accept case directly in the Case detail page.

By default, this is not possible, but with simple tweak, it is possible. Here you go:
  1. Create a custom button in Case object. Follow this step:
  2. Setup - Customize - Cases - Buttons, Links, and Actions
  3. Click 'New Button or Link', select 'Detail Page Button' in Display Type and Behavior select 'Execute JavaScript'
  4. Paste script below
  5. Add custom button created to the Case page layout.
  6. Done

The script:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
var CaseObj = new sforce.SObject("Case"); 

var caseOwner = '{!Case.OwnerId}'; 
var caseOwner3 = caseOwner.substring(0,3); 
//window.alert(caseOwner3); 

if(caseOwner3=='00G') 
{ 
//window.alert("assign case to user"); 
CaseObj.Id = '{!Case.Id}'; 
CaseObj.OwnerId = '{!$User.Id}'; 

var result = sforce.connection.update([CaseObj]); 
location.reload(true); 
} 
else 
{ 
//window.alert("just alert"); 
window.alert("This Case has been handled by someone else"); 
location.reload(true); 
}

This script will check if Case owner is not a Queue, it will not allow user to accept it.
You can enhance with different type to hide Accept button for Case not owned by Queue.

Tuesday, January 7, 2014

Salesforce: find email template associated to which email alerts

This blog in particular is about how to know which email template is associated to which email alerts.

Imagine if you have thousand of email templates created over years by users, how do you able to track if an email template is used in which email alerts of workflow?

Here are the steps on how to create a list view under email alerts:
  1. Click your name and click on Set Up.
  2. Under workflow and approvals click on Email Alerts
  3. On email alerts click on Create New View
  4. From the filters on the view, select Email Template Name field and type in the Email Template Name you would like to check, as your basis to filter.
  5. Click Save and you should be able to see all the email alerts associated with the email template.


More information on Salesforce on Managing Email Alerts and Creating Custom List Views

Monday, January 6, 2014

Salesforce: Approval Process status (2)

Last year, I blog about how to get Approval Process status using SOQL query to ProcessInstance object, see this blog.

Query to ProcessInstance (04g) will give you Status of approval, together with the date/time of when approval submitted and user submit it, see CreatedDate and CreatedById field.
Note: LastModifiedDate and LastModifiedById will NOT change when a user approve / reject an approval request)

If you need more information, such as:
  • Approver username
  • Original approver username
  • Date/time for each transaction
  • Step Status
  • Comments
You can query from ProcessInstanceStep (04h) object, example:
SELECT p.Id, p.ActorId, p.OriginalActorId, p.StepStatus, p.Comments, p.CreatedById, p.CreatedDate, p.ProcessInstance.Status from ProcessInstanceStep p WHERE p.ProcessInstanceId = '04g500000029HCmAAM'



ActorId is the user who is currently assigned the approval step, while OriginalActorId is the user who was originally assigned to this approval step. Query to this object will give full information on the approval steps for each approval.

Another object related to approval, it is ProcessInstanceWorkitem (04i), this object will stored all approval pending request. Meaning approval that has been approved, rejected and recalled will no longer available here. Sample query:
Select p.Id, p.ProcessInstanceId, p.ProcessInstance.Status, p.ProcessInstance.TargetObjectId, p.ActorId, p.OriginalActorId, p.CreatedById, p.CreatedDate from ProcessInstanceWorkitem p


For query to ProcessInstanceWorkitem, actually you can run Salesforce report All Pending Approval Requests. This is standard Salesforce report available from 'Administrative Reports' folder. 

And screenshot below for the result and compare with query result above.


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:


Page-level ad