Thursday, 7 August 2014

CRM 2013 no code approval process - Version 2.0

22:26 Posted by Elaiza Benitez ,
I have a previous vlog post where I showed how to create a simple approval process without code. This was more of a proof of concept of how an approval process could be achieved using customisations - zero development. I've since implemented the approval process for a client but it's somewhat changed from what you last saw. I demonstrated this new version of the approval process at the Melbourne CRM User Group earlier this week.

The client requirement is to prevent a Salesperson from progressing to the next stage/phase of an Opportunity until the Sales Manager approves an Opportunity.

Previously I used a "Two Option" attribute which is a "Yes/No" field to represent whether the Opportunity is Approved or Not Approved.  This is now repelaced with an "Option Set" attribute which is a dropdown field that contains approval status values. I used real time workflows like last time but the conditions are different and revolve around two of my custom fields. Curious for more? Watch my vlog.


OK, I'll do my best to explain this approval process in writing. Here we go... I used the same customisations as last time.

Custom fields
As mentioned earlier, I now have an Approval Status field which are made up of three values. These are,
  • Awaiting Approval
  • Not Approved 
  • Approved
This Approval Status field is to be used in all three workflows, whereas the other custom field Request Approval is used in two workflows.

Field Security
The Approval Status field is enabled for field security. This means field security profiles need to be created.
  1. Sales Manager has Read and Write access on the Field Security Profile
  2. Salesperson has Read access on the Field Security Profile 
Business Process Flow
Three custom fields is added as required steps in the Business Process Flow. This is to ensure the fields are populated in the Business Process Flow Stage.


If you want to create a new Business Process Flow Stage Category, you need to create a new value that represents your Stage in the Stage Category Global Option Set.

Check out this great blog post on how to do this. Read the section "Adding our custom stage categories."

Real Time Workflows
The star of the approval process is the Real Time workflows.

Workflow #1
Notify the Sales Manager when the Salesperson requests for approval.

The trigger of the workflow is when the Request Approval field changes. This is done in the following scenarios,
  1. The Salesperson is requesting approval for the first time. At this point, the Approval Status is updated from null (this means blank, no value) to Awaiting Approval. The Sales Manager is sent an email. 
  2. The Salesperson is requesting approval after the Sales Mangaer does not approve the Opportunity. At this point, the Approval Status is updated from Not Approved back to Awaiting Approval. The Sales Manager is sent an email. 

One thing I forgot to mention at the CRM User Group is that this workflow needs to be executed as the "Owner of the Workflow" because of how the Approval Status has been enabled as field security.
If the workflow is set to "User who made the changes to the record," you will get an error message. This is because it uses the security role of the User. Since the Salesperson does not have "write" access to the Approval Status field, the workflow will fail as one of the steps is to update the Approval Status to "Awaiting Approval."


Workflow #2
Notify the Salesperson when the Sales Manager updates the Approval Status field.

The trigger for this workflow is when the Approval Status field changes.

This is done in the following scenarios,
  1. The Sales Manager approves the Opportunity record. At this point, the Approved By field is updated to the Sales Manager and the Approval Status is updated to Approved. The Salesperson is sent an email. 
  2. The Sales Manager does not approve the Opportunity record. At this point, the Approved By field is updated to the Sales Manager and the Approval Status is updated to Approved. The "Request Approval" field is also updated back to NO in order of the Salesperson to resubmit a request for the Opportunity to be approved. The Salesperson is sent an email. 


Workflow #3
 In my journey of testing my new approval process, I discover that I still needed an extra 'stop gate' as the Salesperson could still click on "Next Stage" if the Approval Status is Awaiting Approval. This is because the required field in the Business Process Flow stage is now populated so CRM recognizes this and allows the Salesperson to move forward.

I knew that the Salesperson should not progress if Approval Status does not equal Approved,but I also needed a variable that links to the Business Process Flow Stage. I can't control the "Next Stage" button. This led to my investigation as seen in my previous vlog post and how I discovered the function of the Pipeline Phase field. The Pipeline Phase field is being updated to match the Stage of the Business Process Flow each time an end user clicks on "Next Stage." This is because it is linked to the Stage Category Option Set. So what I did was used the Pipeline Phase field in my final workflow. The trigger for this worfklow is when the Pipeline Phase field changes.
  1. If Approval Status does not equal Approved and Stage Category is equal to Close, cancel the workflow and present warning message. 
  2. If Approval Status does not equal Approved and Stage Category does not equal Close, do not cancel the workflow. I did this particular condition because I discovered if I did not provide this then the Salesperson could not move to a previous Sales Stage (eg. Develop) without the error message throwing. 
 

And there you go, you have an approval process using CRM 2013 customisations.

Ta da! This is where I break out into my Captain Planet chant:
 EARTH! Option Set!
 FIRE! Field Security!
 WIND! Business Process Flow!  
WATER! Real Time workflow!
 HEART! CRM 2013!
By your powers combined...
 I AM CAPTAIN PLANET I AM A CUSTOMIZED OPPORTUNITY APPROVAL PROCESS!!!

Wait!! I'm not done though! I would also like to direct you to this blog post of Gareth Tucker (another CRM professional) where I learnt earlier this year about how the Stop Workflow function can be utilized in real time worfklows to prevent certain end user actions. I wouldn't have been able to achieve Workflow #3 if I hadn't read his post earlier this year. Check it out.

Now I'm done :) Thanks for watching and reading.

Also, to all who were patient and stayed to watch me present at the Melbourne CRM User Group - thank you. Big thanks to Rowan and Richard for helping me out with the projector connection problems.

Toodles.

PS: Here's some photos of me in action. Thanks Andre for the photos.