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
  • Hey Enrico,  

    Thanks for the post!  I am doing a more simplified custom advanced workflow on a vagrant localhost SugarCRM instance to test proof of concept. I have been following Robert Gonzalez's example: UnCon 2016 - Advanced Workflow Deep Dive Presentation .  Nothing seems to happen when I attempt to trigger the advanced workflow on an Account Record.  In the process management module it reports that my process definition is 'in progress' but never resolves.  Any thoughts on how I could debug or attempt to troubleshoot what I have done wrong?

    Thanks!

    Matt

  • 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?

  • Hi Kishor Mali,

    In your case for "create meeting" or "create opportunity" wouldn't you be able to just leverage the create record functionality present in the system?

    In any event, the example provided has one action, but it can have N configurable paths (through the PHP file methods). You would have that option as well.

    I am not sure currently of your specific problem though.

    Hope it helps you move forward

    --

    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

Reply
  • Hi Kishor Mali,

    In your case for "create meeting" or "create opportunity" wouldn't you be able to just leverage the create record functionality present in the system?

    In any event, the example provided has one action, but it can have N configurable paths (through the PHP file methods). You would have that option as well.

    I am not sure currently of your specific problem though.

    Hope it helps you move forward

    --

    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

Children
  • Hi Enrico Simonetti,

    Create record functionality is not working in my case, because I have to assign to much customize data while creating opportunity and meeting.

    Opportunity case

    1) Account : I need to attached the account which is already attached to Contact which is present in my current meeting from where I am creating opportunity.

    2) One Meeting to many Opportunities : I created this custom relationship.

    Same complex case is also with Meeting module. That's why I need multiple custom action in workflow.