|
|
Want to know more about Packt's Article Network? Interested in contributing your article ideas? Please visit our FAQ for more information. See More BROWSE
All Titles WordPress Web Services SOA BPEL Web Graphics & Video Web Development RAW Portugues, Espanol, Italiano PHP/MySQL Oracle Open Source Networking & Telephony Moodle Microsoft & .NET Linux Servers Joomla! JBoss Java e-Commerce Drupal CRM Content Management Beginner Guides Architecture and Analysis AJAX Future Titles Recently Published Titles Most of the qualities of an ideal ERP system such as, Total Cost of Ownership, Flexibility, Usability, Integration and many more are implemented by conformance to the technical best practices discussed in this two part article by Anil Kumar Gupta. The Dynamics AX best practice can be grouped into three categories i.e. application design standards, shared standards, and AOT object standards. The first part of this article will discuss Application Design Standards. See More |
Developing a Simple Workflow within SugarCRM
A Very Simple WorkflowIn 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 StagesIf 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 ( 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 WhatIn 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:
This means, of course, that we need to be using some businesses rules. Introducing Business RulesThere are six 'triggers' that will cause the logic hooks to fire:
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:
So, custom/modules/Opportunities/logic_hook.php needs to contain something like: <?php 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 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:
All of the relevant information (i.e. the new stage) is passed to the logic hook by means of the $bean object, and we can obtain the stage from $bean->sales_stage. Now all we have to do is combine this with PHP's switch statement into the ppi_workflow function: switch ($bean->sales_stage) You'll notice from the code that we must use the original SugarCRM sales stage terms and not our new mapping—that only appears on the screen. Next we'll have to add the code to update $bean->assigned_user_id with the ID of our new user: global $db; With the code in place, if you now change the Investigation (or Sales) stage, and then save the Preliminary Investigation (or Opportunity) then you'll see that the assigned user is automatically updated for you. However, this is still only a semi-automatic process—the correct person for the stage is selected correctly, but only if the stage is selected manually. The process running correctly still depends on someone telling SugarCRM what that next stage is. Obviously the next step is to move from stage to stage automatically. Completing the Automated WorkflowAt the moment we're relying on a user telling the application which stage to move to next. However, it would be much better for the user to tell SugarCRM that the current stage has been completed, and then for the business rules to decide which stage should be carried out next. We want to keep it simple and therefore an 'Investigation Stage Complete' checkbox will do the job. If you look at the edit view for any of the existing Opportunities then you'll see that there's nothing that can really be renamed to represent our 'Investigation Stage Complete':
We can use the SugarCRM Studio to add the field that we're going to need:
After adding the custom field itself we'll need to add text for the field label into custom/modules/Opportunities/language/en_us.lang.php: And then we're ready to see the new edit view: $mod_strings['lbl_chk_complete_c_10'] = "Investigation Stage
We can now go back to our code (in custom/include/ppi_workflow.php), and we can place all of our functionality within an if statement: if ( $bean->chk_complete_c == 1 ) Our logic hook will, of course, fire every time a save is made—but our business rule will only be implemented if the Investigation Stage Completed box is ticked. So now we need the code that will define the process itself, and you would need to place this before the code for deciding who the assigned user is: switch ($bean->sales_stage) And finally we need to reset the completed status back to 0: $bean->chk_complete_c = 0; You'll notice that we've not taken the process all the way to the final stage—this is because the final two stages are 'Closed won' or 'Closed lost' (in PPI speak—'Full Investigation required' and 'Insufficient Evidence'). Korora will need to make that decision herself. However, the important thing is that you can see just how easy it is to set up a simple process (not that any process is ever simple). SummaryBefore you start work on your workflow, ensure that: the people who understand the processes in the organization are available to you; both managers and staff agree that the process plan is correct; staff don't feel that the process is being enforced on them; and that this isn't another case of 'Big Brother'. When you do start building the work flow ensure that you've correctly mapped your organization's stages onto the SugarCRM stages and that you have a complete listing of who does what and when. Business rules are created by making use of SugarCRM's logic hooks. The logic hook file contains the priority of the business rule, the name of the businesses rule, the file containing the business rule, the business rule class, and the business rule function.
About the AuthorDr. Mark Alexander Bain first started customizing CRM systems back in the mid '90s when he was team leader for Vodafone's Cascade project – the team took the 'out-of-the-box' Clarify CRM and turned it into a radio base station planning application, complete with a workflow engine for passing jobs between the different departments involved in the planning, building, and implementation of a radio network. Since then he's lectured at the University of Central Lancashire, and currently Mark writes articles on all things Linux and Open Source for Linux Format, Newsforge.com and Linux Journal. SugarCRM customization, therefore, seems the obvious choice for this, his second book, since it combines Mark's knowledge of working with commercial CRMs and the Open Source philosophy. Mark works from his home on the edge of the Lake District in the UK, where he lives with his wife, two dogs and two cats, and gets the odd visit from his sons – Michael and Simon.Books from Packt
|
|
| ||||||||