Extending Advanced Workflow - Customizing actions

Hello,

Accordingly to Sugar 7.8 Technical Overview, I am trying to extend the advanced workflow by followingthe exemple given (Capitallize action ).

The goal is to capitallize every fields of the bean given.

I created 3 files :
My JSGrouping located in : custom\Extension\application\Ext\JSGroupings\capitalize_action.php
My custom action definition call in : custom\include\javascript\psme\capitalize_action.js
And my custom action class located here : custom\modules\pmse_Inbox\engine\PMSEElements\CustomPMSECapitalizeName.php

I did a quick create and rebuild and I repaired Javascript and JS Groupings.

I also reloaded the entire page but I can't see my customized action in PMSE.

Did I forget anything ?

Many thanks,
Regards,
Bastien.

4370._CustomPMSECapitalizeName.php.txt.zip

8272._capitalize_action.js.txt.zip

8446._capitalize_action.php.txt.zip

Parents
  • Create these file to make it work. I have tested it on SugarCRM v 7.8.

    custom/include/javascript/pmse/capitalize_action.js

    AdamActivity.prototype.customContextMenuActions = function() {
        return [{
            name: 'CAPITALIZE_NAME',
            text: 'Capitalize Record Name'
        }]
    };

    AdamActivity.prototype.customGetAction = function(type, w) {
        switch (type) {
            case 'CAPITALIZE_NAME':
                var actionText = 'Capitalize the Record Name (Action)';
                var actionCSS = 'adam-menu-icon-configure';
                var disabled = false;
                return {
                    actionText: actionText,
                    actionCSS: actionCSS,
                    disabled: disabled
                }
        }
    };

    custom/Extension/application/Ext/JSGroupings/capitalize_action.php

    <?php

    foreach ($js_groupings as $key => $groupings)
    {
        foreach  ($groupings as $file => $target)
        {
             //if the target grouping is found
            if ($target == 'include/javascript/pmse.designer.min.js')
            {
                //append the custom JavaScript file
                $js_groupings[$key]['custom/include/javascript/pmse/capitalize_action.js'] = 'include/javascript/pmse.designer.min.js';
            }
            break;
        }
    }

    custom/modules/pmse_Inbox/engine/PMSEElements/CustomPMSECapitalizeName.php

    <?php

    require_once 'modules/pmse_Inbox/engine/PMSEElements/PMSEElement.php';

    /**
    *
    */

    class CustomPMSECapitalizeName extends PMSEElement implements PMSERunnable
    {
        
         public function run($flowData, $bean=null, $externalAction = '', $arguments = array())
         {
              $this->capitalizeName($bean);
              $flowAction = $externalAction === 'RESUME_EXECUTION' ? 'UPDATE' : 'CREATE';
              return $this->prepareResponse($flowData, 'ROUTE', $flowAction);
         }

         public function capitalizeName($bean)
         {
                    //Change the field name according to your module
              $bean->name = strtoupper($bean->name);
              $bean->save();
         }
    }

    After creating these files perform these steps:

    1. Quick Repair and Rebuild
    2. Rebuild JS Grouping Files

    Refresh process definition designer page and you will see Capitalize Record Name Action.

Reply
  • Create these file to make it work. I have tested it on SugarCRM v 7.8.

    custom/include/javascript/pmse/capitalize_action.js

    AdamActivity.prototype.customContextMenuActions = function() {
        return [{
            name: 'CAPITALIZE_NAME',
            text: 'Capitalize Record Name'
        }]
    };

    AdamActivity.prototype.customGetAction = function(type, w) {
        switch (type) {
            case 'CAPITALIZE_NAME':
                var actionText = 'Capitalize the Record Name (Action)';
                var actionCSS = 'adam-menu-icon-configure';
                var disabled = false;
                return {
                    actionText: actionText,
                    actionCSS: actionCSS,
                    disabled: disabled
                }
        }
    };

    custom/Extension/application/Ext/JSGroupings/capitalize_action.php

    <?php

    foreach ($js_groupings as $key => $groupings)
    {
        foreach  ($groupings as $file => $target)
        {
             //if the target grouping is found
            if ($target == 'include/javascript/pmse.designer.min.js')
            {
                //append the custom JavaScript file
                $js_groupings[$key]['custom/include/javascript/pmse/capitalize_action.js'] = 'include/javascript/pmse.designer.min.js';
            }
            break;
        }
    }

    custom/modules/pmse_Inbox/engine/PMSEElements/CustomPMSECapitalizeName.php

    <?php

    require_once 'modules/pmse_Inbox/engine/PMSEElements/PMSEElement.php';

    /**
    *
    */

    class CustomPMSECapitalizeName extends PMSEElement implements PMSERunnable
    {
        
         public function run($flowData, $bean=null, $externalAction = '', $arguments = array())
         {
              $this->capitalizeName($bean);
              $flowAction = $externalAction === 'RESUME_EXECUTION' ? 'UPDATE' : 'CREATE';
              return $this->prepareResponse($flowData, 'ROUTE', $flowAction);
         }

         public function capitalizeName($bean)
         {
                    //Change the field name according to your module
              $bean->name = strtoupper($bean->name);
              $bean->save();
         }
    }

    After creating these files perform these steps:

    1. Quick Repair and Rebuild
    2. Rebuild JS Grouping Files

    Refresh process definition designer page and you will see Capitalize Record Name Action.

Children
  • Hi Altaf Ur Rehman,

    I applied method you suggested. It worked fine. But I want to write two different custom methods. Below is observation if we write two different methods.

    Let's consider, Method 1 is already implemented and working fine and we can see Method 1 in Advanced Workflow Action tool. I created Method 2 using same method as suggested above. Now in Advanced Workflow Action tool, Method 1 option is not available. If we select Method 2 for action, Method 1 is executed. 

    Do you have any idea about how to add two different custom actions for Advanced Workflow?