Pages

Wednesday, August 13, 2014

Ten things you need to know about Activity in Salesforce



1. Activity contains Event and Task, they are stored as two separate objects, but you can run report as Activity which contain data from both object.

2. Completed Task will move from Open Activities to Activity History in page layout related list, the same for Event when Due Date is over.

3. By default, there is no Task or Event tab - Activities Tab and View (Event or Task)

4. Activities archive over one year - Archived Activities

5. Not possible to create custom lookup field on Activity (delivered in Winter '16)

6. Cannot assigned to a Queue ; vote for this idea Allow Task(s) to be assigned to a Queue

7. Sharing setting only Controlled By Parent or Private

8. There is no option to create workflow with email alert action - No Email Alert action for Task & Event Workflow ; vote for this idea Email Alerts for Activity Workflows

9. Workflow with field update action on Task cannot update some standard Task fields, like: Due Date, Name, Related To

10. You can create Task from workflow, but it only will have one: Name (Who) or Related To (What), it depends on the Task action related to which object.


Monday, August 11, 2014

Salesforce: Merge Field for User Object in Email Template

Email Alert in Workflow in Salesforce.com is simply awesome and easy to configure. The feature has been available since long time back. This blog is not going to discuss how to create Email Alert for Workflow, but you can read it through this documentation.

To make the email more meaningful, admin can add merge fields into the email subject or body. Rather than a static email "A case has been created", it is much meaningful to have email with message "A High priority case has been created - No: 001001" and email body contain more information, such as: Subject, Type, Priority, etc.

Admin just need to create an Email Template with merge fields from any object, from: Contact, Lead, including custom objects. Read this documentation.

Use Case: send email alert to a public group when a Salesforce user (not Chatter only user) has been deactivated.

1. Create Email Template
Subject: {!User.Region__c} Salesforce user has been deactivated - {!User.Name}
Body:
Hello,

Please note following user has been deactivated:
Name: {!User.Name}
Username - Region: {!User.Username} - {!User.Region__c}

Link: {!User.Link}

regards,
Salesforce.com


2. Create Email Alert
Make sure to select Public Group as Recipients and correct Email Template.


3. Create Worklow
Object = User
Evaluation Criteria = Evaluate the rule when a record is created, and every time it’s edited
Rule Criteria =
TEXT(UserType) = "Standard" && 
IsActive = False &&
PRIORVALUE(IsActive) = True

Add Email Alert above as immediate workflow actions and DONE!

But, wait a minute... something wrong with user information in the email received, merge field in email template have information of the user who has actually deactivate the user i.e. system admin and NOT the user which has been deactivated.

Good news in Summer '14 release, Salesforce introduce Workflow Target User Merge Fields for Email Templates, by changing merge field from !User to !Target_User, simply modified above email template:

Subject: {!Target_User.Region__c} Salesforce user has been deactivated - {!Target_User.Name}
Body:
Hello,

Please note user following user has been deactivate:
Name: {!Target_User.Name}
Username: {!Target_User.Username} - {!Target_User.Region__c}

Link: {!Target_User.Link__c}

regards,
Salesforce.com

If you notice last merge field above for link {!Target_User.Link__c}, it is a custom field, just change it to to {!Target_User.Link} will not work. Further search and test found that


This maybe a defect as currently it still Beta. So, the workaround, I create custom formula field in user object "https://xyz.salesforce.com/" & Id & "?noredirect=1" (change xyz to your Salesforce instance) - done !!


Reference:

Friday, July 11, 2014

Salesforce: Serial and Parallel Approval

Approval process has been introduced in Salesforce platform sometimes back. But when someone ask you, if Salesforce support Parallel and Serial approval process?

The answer is YES, although Salesforce do not implicitly said it is parallel or serial approval process.

The good thing is, this functionality available out of the box. So you do not need to write any code. Just with point and click configuration, you can build this process within hours.


Parallel Approval
Parallel Approval means you are sending multiple approvals out in one step of the approval process. Any approver able to approve without need to wait for other approvers to approve.

The approver can be specific users, a queue or related user in the record.

How to configure this in Salesforce?
When you reach Approval Steps - Select Assigned Approver, choose Automatically assign to approver(s)

In sample above, when user submit for approval, it will go to a user 'Maria Ann' and also go to 'Finance Queue' at the same time. Maria do not need to wait a user from Finance queue to approve, and the same for user in Finance queue can approve without have to wait Maria approval.

You also can specify whether only the first approval is needed or ALL approval need to approve, when all approved, it will move to the next step of approval process. It is configured in above screen at When multiple approvers are selected. When you select "Require unanimous approval from all selected approvers." the record is only approved if all of the approvers approve the request. The approval request is rejected if any of the approvers reject the request.

Note: approval assigned to a queue, it does not mean ALL users in the queue have to approve, when one of the user in queue approve, it is considered as Approve from the queue.

Here is a screenshot once user submit for approval, it will go to both user and queue for this sample.

This when Linda from Finance has approved


Serial Approval
Serial Approval means after a user approve, it will move to the next user to approve. Most use case for this when next approval is needed when it hit certain criteria, example:
1. When discount given < 10%, only Sales Manager need to approve, but
2. When discount given >= 10%, after Sales Manager approved, it also need to be approved by Sales Director. So, Sales Director only need to approve when it has been approved by Sales Manager.

How to configure this in Salesforce?
When you reach Approval Steps, you need to create multiple steps. Each steps may have different criteria. See screenshot below for the details.

When user submit for approval, he will only see the immediate approver only:

When Linda approve, because discount for this opportunity is more than 10%, it will go to the next approver


You can click View Diagram button in Approval Process to display the flow, you also can click each item to show the properties.



Last one, you also can combine both parallel and serial approval in an approval process. Example: after Sales Manager approve, it will go to Sales Director approval and also Ops Director approval, both user need to approve, so we select Require UNANIMOUS approval from all selected approvers.


Reference: Creating Approval Steps



Thursday, July 10, 2014

Salesforce URL Parameters


When you work with Salesforce for daily job, you may notice the URL is keep changing based on activity you work on.

This blog list unofficial information gathered based on multiple sources and personal experience. Salesforce do not support any implementation based on URL hack. But, for some Salesforce administrator, it is good to know to make our self productive for daily work with Salesforce.com

Using this technique, you can create custom button / link to pre-populate value when create new record.

Here list of the parameters collected, if you know any standard parameters and not listed here, let me know to add it:

Home Tab
Go to home tab
URL: /home/home.jsp
Example: https://na3.salesforce.com/home/home.jsp

Salesforce1
View as Salesforce1 mobile app
URL: /one/one.app
Example: https://na3.salesforce.com/one/one.app
This is no longer valid after Lightning Experience introduced.

Login Parameter
This is not a good practice to send clear text in web browser
URL: /login.jsp?un=<username>&pw=<password>
Example: https://www.salesforce.com/login.jsp?un=user@email.com&pw=secret

Object View
Open an object in list View without the need to create a tab
URL: /<object prefix>
Example: https://na3.salesforce.com/001

Object Tab
Open an object tab
URL: /<object prefix>/o
Example: https://na3.salesforce.com/001/o

View Record
Open a record in page layout
URL: /<record id>
Example: https://na3.salesforce.com/0015000000tC2gZ

Download file
Download a file stored as attachment or document
URL: /servlet/servlet.FileDownload?file=<record id>
Example: https://na3.salesforce.com/servlet/servlet.FileDownload?file=01550000000gdVu

Mini Page Layout
This is the view when user hover the parent record from a child record page layout
URL: /<record id>/m
Example: https://na3.salesforce.com/0015000000tC2gZ/m

Printable View
Open a record as user click Printable View link at the top right of the page
URL: /<record id>/p
Example: https://na3.salesforce.com/0015000000tC2gZ/p

Transfer a Record
Transfer record owner
URL: /<record id>/a
Example: https://na3.salesforce.com/0015000000tC2gZ/a

Create a new Record
Create a new record using default record type (if any)
URL: /<object prefix>/e
Example: https://na3.salesforce.com/001/e

Create a new Record with Record Type
Create a new record with Record Type parameter
URL: /<object prefix>/e?RecordType=<record type id>
Example: https://na3.salesforce.com/001/e?RecordType=01250000000HeOC

Edit a Record
Edit an existing record 
URL: /<record id>/e
Example: https://na3.salesforce.com/0015000000tC2gZ/e

Clone a Record
Edit an existing record 
URL: /<record id>/e?clone=1
Example: https://na3.salesforce.com/0015000000tC2gZ/e?clone=1

Cancel a Record
When user create or edit a record, if user click Cancel button retURL parameter will bring user back to a record specified.
URL: /<record id>/e?retURL=<record id> or /<object prefix>/e?retURL=<object prefix>/o
Example: https://na3.salesforce.com/0015000000tC2gZ/e?retURL=0015000000tC2gZ

Create Task & Event and relate it to Account and Contact
Use 00U for Event and 00T for Task, you can use any standard objects for what_id except: Contact & Lead, this is include custom objects with enable Track Activities. While for who_id you can use Contact & Lead.
URL: /00T/e?what_id=<account record id>&who_id=<contact record id>
Example: https://na3.salesforce.com/00T/e?what_id=0015000000qj947&who_id=00350000023g0qu


Reference:


Sunday, July 6, 2014

Salesforce: Unlock Record button

Few months ago, I wrote a blog about who able to Edit Locked Record in Salesforce. Record owner and standard user would not able to edit the record, it will show a pad lock icon next to Edit button. When user click Edit button, the user will get error message Record Locked, The record you are trying to edit has been locked. Please contact your administrator if access is necessary.



Until now (July 2014), record locking mechanism in Salesforce only can be initiate from Approval Process. Some users will see Unlock Record button next to Edit button. Clicking that button will unlock the record, and the record become editable by record owner and standard users.



Compare with screenshot below when view by record owner or other user as below.



So, who will see the Unlock Record button and able to unlock the record:
1. User with System Administrator profile
2. User with Modify All Data permission
3. User with Modify All permission in the object locked

Once a record is unlock:
1. Pad lock icon will be disappear
2. Record owner or users with ability to edit the record will able to edit the record
3. In the object history, it will show date/time, user with action 'Record unlocked.'


4. The approval process for the record still in place, approver still able approve or reject the record.




Reference: Edit Locked Record



Saturday, July 5, 2014

Salesforce: Object Prefix

For Salesforce administrators and developers with years of experience work in Salesforce area, all of us should know 0015000000tCKZx is an Account record while 00350000023hJC0 is a Contact. You can easily note this from the web URL. This also serves as record Id whether as 15 or 18 characters. Look at the first 3 characters prefix, we can determine what is the object behind that record in both Standard and Custom object.

Standard Object
For a standard object, all the prefix is the same. I am not going to re-list each Standard object with the correspondence prefix, as many of fellow blogger and Salesforce article has listed it:

Custom Object
Each custom object has a unique prefix for each instance, it is the same with a standard object where prefix length = 3 characters. You can notice it in the URL when open the record or click custom object tab for that object. Here a blog is written sometimes back to get a tab view without having to create custom object tab - Hidden Tab for Custom Object

But, if the object just created and no tab is created for it, you would be a little difficult to get the prefix as it is not stated anywhere in Salesforce. Here is the workaround - use a free tool Developer Workbench

Once you login, go to Standard & Custom Objects menu, select the object from the dropdown menu and look for keyPrefix, see screenshot below:



Another use case, you have a Salesforce record Id, but you do not know what is the object for that record Id. Go through each object using Developer Workbench is way too hard. Use Developer Console with simple apex script will easily find the object. Click your name in Salesforce then click Developer Console


Once Developer Console open, click Debug then Open Execute Anonymous Window



It will show last apex code executed (if any), change the code as below (remember to change the Id), then click Execute button - also make sure to select Open Log checkbox


Apex code: System.debug(System.LoggingLevel.ERROR, Id.valueOf('01Q50000000IhVI').getSObjectType());


See the highlight, 01Q50000000IhVI is a record for Competitor__c custom object.

If you are confused or hard to find the object name, select Debug Only checkbox, it will filter only to show object that you are looking for.

above screenshot is not related to earlier debug


Using Developer Console also can find prefix as we did using Developer Workbench, use following apex code: 
Schema.DescribeSObjectResult r = CustomObject__c.sObjectType.getDescribe();
String keyPrefix = r.getKeyPrefix();
System.debug('Printing --'+keyPrefix );

Or in one line command:
System.debug('keyPrefix: ' + CustomObject__c.SObjectType.getDescribe().getKeyPrefix());

Change CustomObject__c to your real object API name. Here is the result:



RegEx to validate Salesforce Id
If you familiar with RegEx, here is the regex to validate Salesforce Id 
a-zA-Z0-9]{15,18}



Page-level ad