Dynamic dropdown

Hi all, 


I have to get dynamic dropdown in module. It should get record name of other module as dropdown values based on selection of another standard dropdown field.

Can any one please help on this. 

Parents
  • Hi Lokesha L N,

    If I understood well, you want a dropdown filled with the module names available on your SugarCRM instance.

    I reached that creating a custom SugarLogic expression which returns the module list. It would be something like the below, the file custom/include/Expressions/Expression/Enum/ModuleListExpression.php:

    require_once('include/Expressions/Expression/Enum/EnumExpression.php');

    class ModuleListExpression extends EnumExpression {

        function evaluate() {
            return array();
        }

        static function getJSEvaluate() {
            return <<<EOQ
            var moduleList = SUGAR.App.metadata.getFullModuleList();
            var moduleNames = [];
            moduleNames[0] = '';
            var i = 1;
            for( var key in moduleList ) {
                moduleNames[i] = key;
                i++;
            }
            return moduleNames;
    EOQ;
        }

        static function getOperationName() {
            return 'getModuleList';
        }

        static function getParamCount() {
            return 0;
        }

        static function getParameterTypes() {
            return array();
        }

    }

    Then perform a Rebuild SugarLogic expressions from the Admin section.

    In order to use the function, something like the below should work (using the SetOptions dependency action):

    in custom/Extension/<module>/Ext/Dependencies:

    $dependencies['<your_module_name>']['modulelist'] = array(
        'hooks' => array("edit","save"),
        'trigger' => 'true',
        'triggerFields' => array('<your_field_name>'),
        'onload' => true,
        'actions' => array(
            array(
                'name' => 'SetOptions',
                'params' => array(
                    'target' => '<your_field_name>',
                    'keys' => 'getModuleList()',
                    'labels' => 'getModuleList()'
                ),
            ),
        ),
    );

    You should adapt the code in order to match your own expectations.

    Hope this helps.

    Regards,

    David.

Reply
  • Hi Lokesha L N,

    If I understood well, you want a dropdown filled with the module names available on your SugarCRM instance.

    I reached that creating a custom SugarLogic expression which returns the module list. It would be something like the below, the file custom/include/Expressions/Expression/Enum/ModuleListExpression.php:

    require_once('include/Expressions/Expression/Enum/EnumExpression.php');

    class ModuleListExpression extends EnumExpression {

        function evaluate() {
            return array();
        }

        static function getJSEvaluate() {
            return <<<EOQ
            var moduleList = SUGAR.App.metadata.getFullModuleList();
            var moduleNames = [];
            moduleNames[0] = '';
            var i = 1;
            for( var key in moduleList ) {
                moduleNames[i] = key;
                i++;
            }
            return moduleNames;
    EOQ;
        }

        static function getOperationName() {
            return 'getModuleList';
        }

        static function getParamCount() {
            return 0;
        }

        static function getParameterTypes() {
            return array();
        }

    }

    Then perform a Rebuild SugarLogic expressions from the Admin section.

    In order to use the function, something like the below should work (using the SetOptions dependency action):

    in custom/Extension/<module>/Ext/Dependencies:

    $dependencies['<your_module_name>']['modulelist'] = array(
        'hooks' => array("edit","save"),
        'trigger' => 'true',
        'triggerFields' => array('<your_field_name>'),
        'onload' => true,
        'actions' => array(
            array(
                'name' => 'SetOptions',
                'params' => array(
                    'target' => '<your_field_name>',
                    'keys' => 'getModuleList()',
                    'labels' => 'getModuleList()'
                ),
            ),
        ),
    );

    You should adapt the code in order to match your own expectations.

    Hope this helps.

    Regards,

    David.

Children