Extend Advanced Workflow configurable actions to trigger custom PHP code

Here it is a ready-to-use example on how to extend Advanced Workflows leveraging UI configurable custom PHP actions. It is based on the original example from SugarCON last year.

I've made it so that it is module aware (the developer can define module specific methods) and the method to call can be configured from the UI (only module specific methods will appear on the workflow).

The code is here: https://github.com/esimonetti/SugarAdvancedWorkflowCustomPHPMethods 

It will be extremely beneficial in situations where complex actions are required (eg: multiple lookups and records save at once), and UI action configuration/selection at the workflow level is required. The admin users with this type of customisation can have control on when and how the complex actions executed on the PHP side are triggered and have the flexibility to change the conditions that trigger them through the workflow UI.

The custom actions can be sent to the background and executed from the PHP side asynchronously, leveraging further our product's job queue to improve UI responsiveness for end users.

This should not be used as the silver bullet for everything, but it is a solid example to start with.

Feel free to have a look at the repository for more info!

Cheers

Parents Reply Children
  • Hi Brian,

    Not a problem!

    I would start by adding some logging on the PHP logic side, to see if that's triggered.

    I would also look at the php error logs, to see if there is any PHP error showing up as well. There might be a PHP syntax error?

    You have examples available here https://github.com/sugarcrm/uncon/tree/2017/advanced-workflow and here https://github.com/sugarcrm/uncon/tree/2016/awf_deep_dive 

    Cheers

    --

    Enrico Simonetti

    Sugar veteran (from 2007)

    www.naonis.tech


    Feel free to reach out for consulting regarding:

    • API Integration and Automation Services
    • Sugar Architecture
    • Sugar Performance Optimisation
    • Sugar Consulting, Best Practices and Technical Training
    • AWS and Sugar Technical Help
    • CTO-as-a-service
    • Solutions-as-a-service
    • and more!

    All active SugarCRM certifications

    Actively working remotely with customers based in APAC and in the United States

  • Brian Hearn,

    Are you using the code examples as-is without any changes, to start with? How did it go?

    --

    Enrico Simonetti

    Sugar veteran (from 2007)

    www.naonis.tech


    Feel free to reach out for consulting regarding:

    • API Integration and Automation Services
    • Sugar Architecture
    • Sugar Performance Optimisation
    • Sugar Consulting, Best Practices and Technical Training
    • AWS and Sugar Technical Help
    • CTO-as-a-service
    • Solutions-as-a-service
    • and more!

    All active SugarCRM certifications

    Actively working remotely with customers based in APAC and in the United States

  • This has so many possibilities to overcome the limitations of the current process workflows. I can't wait to give it a try.  awesome work - thank you!

  • I want multiple custom actions in Workflow.

    In activity.js, I have tried the code as follows, but it doesn't work. Anyone tried such scenario of creating multiple custom action in workflow.

    AdamActivity.prototype.customContextMenuActions = function() {
    return [{
      name: 'CREATE_OPPORTUNITY',
      text: 'Create Opportunity'
    }, {
      name: 'CREATE_MEETING',
      text: 'Create Meeting'
    }]
    };

    AdamActivity.prototype.customGetAction = function(type, w) {
    switch (type) {
    case 'CREATE_OPPORTUNITY':
    var actionText = 'Create Opportunity (Action)';
    var actionCSS = 'adam-menu-icon-configure';
    var disabled = false;
    return {
    actionText: actionText,
    actionCSS: actionCSS,
    disabled: disabled
    };
    case 'CREATE_MEETING':
    var actionText = 'Create Meeting (Action)';
    var actionCSS = 'adam-menu-icon-configure';
    var disabled = false;
    return {
    actionText: actionText,
    actionCSS: actionCSS,
    disabled: disabled
    }
    }
    };

    /**
    * Needed to define the modal that pops up with a form
    * @param {string} type The action type
    * @return {object} Definition needed for a modal
    */
    AdamActivity.prototype.customGetWindowDef = function(type) {
    switch(type) {
    case 'CREATE_OPPORTUNITY':
    var wWidth = 500;
    var wHeight = 140;
    var wTitle = 'Create Opportunity';
    return {wWidth: wWidth, wHeight: wHeight, wTitle: wTitle};
    case 'CREATE_MEETING':
    var wWidth = 500;
    var wHeight = 140;
    var wTitle = 'Create Opportunity';
    return {wWidth: wWidth, wHeight: wHeight, wTitle: wTitle};
    }
    }

    In Workflow Action menu, I got only one action at a time. I want 2 or more action over there. Anyone tried this scenario?