Pages

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.


ReferenceCreating 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.




ReferenceEdit 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 in the web page URL. This also serve as record Id whether as 15 or 18 characters. Looking the first 3 characters prefix, we can  determine what is the object behind that record in both Standard and Custom object.

Standard Object
For 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 list it:

Custom Object
Each custom object have unique prefix for each instance, it is the same with 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 written sometimes back to get a tab view without have to create custom object tab - Hidden Tab for Custom Object

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

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

Another use case, you have a Salesforce record Id, but 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 to following and click Execute button.

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


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

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}