Workflow is about getting the right work to the right people at the right time, repeatedly—and knowing you have done so. Workflow is human-centric. First and foremost, workflow is a human activity that is made by and for those who use it: workflow is something that can easily be handled and understood by human beings.
UK Enterprise Workflow National e-Government Project—Workflow from a Business Perspective
Well, that sounds good, but the problems start to occur when you ask people to consider workflow in their organization, and there are usually a few main issues to deal with:
- You'll find that people are normally experts in their own fields—there are often very few people who have an overview of the whole process that you're trying to map.
- Sections of a large organization will often have different ways of carrying out the same overall process.
- People don't really like to be told how to do their jobs—they especially don't like to have any extra processes imposed on them for now obvious reason—well, would you?
- Talk of 'improved utilization of resources', 'improved performance monitoring', and such like can soon alienate the staff who are going to be using the system. They'll soon start using terms such as 'Big Brother'.
How you are able to deal with these will depend on your organization and the people that are available to you. At least once you've read this article by Dr. Mark Alexander Bain, you'll know that, once you've overcome those problems, the workflow itself will be easy.
A Very Simple Workflow
In our simple workflow we'll assume that each task is carried out by one person at a time, and that all tasks are done sequentially (i.e. none are done in parallel). So, we'll look at the PPI Preliminary Investigation which, as you remember, maps to the standard SugarCRM Opportunity. Also, in this example, we're going to have a different person carrying out each one of the Investigation stages.
Setting up the Process Stages
If you look at SugarCRM then you'll see that by default none of the stages are related to investigations—they're all named using standard CRM terms:

Obviously the first thing to do is to decide what the preliminary investigation stages actually are, and then map these to the SugarCRM stages. You'll realize that you'll need to edit the custom/include/langauge/en_us.lang.php file:
$app_list_strings['sales_stage_dom']=array (
'Prospecting' => 'Fact Gathering',
'Qualification' => 'Witness and Subject Location',
'Needs Analysis' => 'Witness and Subject Interviews',
'Value Proposition' => 'Scene Investigation',
'Id. Decision Makers' => 'Financial and background Investigation',
'Perception Analysis' => 'Document and evidence retrieval',
'Proposal/Price Quote' => 'Covert Camera surveillance',
'Negotiation/Review' => 'Wiretapping',
'Closed Won' => 'Full Investigation required',
'Closed Lost' => 'Insufficient Evidence',
);
Don't forget that you can also do this via Studio. However, once you've added your mapping into custom/include/langauge/en_us.lang.php file, and refresh your browser, then you'll see the new stages:

Now that our stages are set up we need to know who'll be carrying out each one.
Deciding Who Does What
In our simple workflow there may not be the need to do anything further. Each person just needs to know who does what next:
For example, once Kurt finishes the 'Covert Camera surveillance' stage then he just needs to update the Preliminary Investigation so that the stage is set to 'Wiretapping' and the assigned user as 'dobbsm'.
However, things are rarely as simple as that. It's much more likely that:
- Investigations may be based on geographical locations, so that the above table may only apply to investigations based in London. Investigations based in New York follow the same process but with a different set of staff.
- On Mondays Fran does 'Witness and Subject Location' and William does 'Fact Gathering'.
This means, of course, that we need to be using some businesses rules.
Introducing Business Rules
There are six 'triggers' that will cause the logic hooks to fire:
- after_retrieve
- before_save
- before_delete
- after_delete
- before_undelete
- after_undelete
And the logic hooks are stored in custom/modules/<module name>/logic_hook.php, so for 'Preliminary Inquiries' this will be custom/modules/Opportunities/logic_hook.php. You'll also remember, of course, that the logic hook file needs to contain:
- The priority of the business rule
- The name of the businesses rule
- The file containing the business rule
- The business rule class
- The business rule function
So, custom/modules/Opportunities/logic_hook.php needs to contain something like:
<?php
#As always ensure that the file can only be accessed through SugarCRM
if(!defined('sugarEntry') || !sugarEntry) die(
'Not A Valid Entry Point');
$hook_array = Array(); #Create an array
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(1, 'ppi_workflow',
'custom/include/ppi_workflow.php',
'ppi_workflow', 'ppi_workflow');
?>
Next we'll need the file that logic hook will be calling, but to start with this can be very basic—so, custom/include/ppi_workflow.php just needs to contain something like:
<?php
#Define the entry point
if(!defined('sugarEntry') || !sugarEntry) die(
'Not A Valid Entry Point');
#Load any required files
require_once('data/SugarBean.php');
require_once('modules/Opportunities/Opportunity.php');
#Define the class
class ppi_workflow
{
function ppi_workflow (&$bean, $event, $arguments)
{
}
}
?>
With those two files set up as above nothing obvious will change in the operation of SugarCRM—the logic hook will fire, but we haven't told it to do anything, and so that what we'll do now.
When the logic hook does run (i.e. when any Primary Investigation is saved) we would want it to:
- Check to see what stage we're now at
- Define the assigned user accordingly
Sign up for a Packt account to see the rest of this article
Now that you've read a few articles, you might want to consider signing up for a Packt account. It takes a matter of seconds, will give you access to all the articles on PacktPub.com, and once you've signed up you'll be returned here to carry on reading your article.
Furthermore, you'll gain access to nine free ebooks, and be offered a free trial of PacktLib, Packt's online library. Simply enter your details here, or log in to your existing account.




Post new comment