Editor’s Note: This blog post comes from Bill Convis of SierraCRM, and talks about how his team worked with our top notch engineering team to find a way to add action menu items across multiple modules. Big thanks to Bill for the writeup, and Peter DeMartini of SierraCRM, and David Wheeler of SugarCRM for helping form the solution.
With the release of SugarCRM 7 came new challenges and opportunities for SugarCRM technology partners. An entirely new paradigm was offered for solution providers to add new features to the power of SugarCRM. Process Manager Enterprise (PM) from SierraCRM, a workflow solution that augments SugarCRM’s existing workflow, was being updated to take advantage of the new architecture.
One of the features to be added to the new release of PM was the ability to see all the processes for a single object. Our intent was to show both processes that had been completed and process that were currently active.
After reviewing the options, a decision was made to add an “action item” to a record view to display a drawer with a listing view of the processes for that record.
We approached John Mertic at SugarCRM and asked him if there was an extensible framework for action buttons, as we wanted to build a solution that was both upgrade safe and would be global across all modules. He suggested we meet with the engineers at SugarCon.
At the SugarCon 2014 conference in San Francisco, Sierra’s senior developer, Peter DeMartini, met up with SugarCRM Engineer David Wheeler at one of the hacker sessions.
This new file would be ./custom/clients/base/layouts/record/record.php.
The final file that was created with the help from David (this was the most important piece for us) was the pm-record-logic.js file. David suggested we extend the initialize function , call the _super method and then bind our code to the click event for the button created above. The code snippet is:
We will now present the code in its entirety with instructions for other solution providers to accomplish the same thing:
The first file is record.php and lives in ./custom/clients/base/views/record/record.php
This file adds the action button to the action menu. The ‘name’ => ‘pm_record_reports’ will map to a file ./custom/clients/base/views/pm-record-logic/pm-record-logic.js with an initialize function that will set this buttons name to a click event function.
The next file is also named record.php and lives in ./custom/clients/base/layouts/record/record.php
What is key in this file is the ‘layout’ => ‘pm-record-logic’. Which allows us to inject our custom view into every record view.
Our first file is:
And our handle bars file ./custom/clients/base/views/pm-record-logic/pm-record-logic.hbs
And finally our pm-record-logic.js file which makes the api call to Process Manager to retrieve all the processes for the given object:
The remaining files used in this customization are the view and layouts for the actual data returned by Process Manager to be shown in the drawer.