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. 

  • Hi Lokesha L N 

    Le me check if I got your request:

    Do you want to render a dropdown populated with records from a related module and filtered by some regular dropdown?

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • 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.

  • Hi André Lopes and David López,

    I need dynamic dropdown fields like i should get product catalog name as dropdown field 2 based on selection of product catagory as dropdown field 1.


    Waiting for your help, 

    Thanks in advance, 

    Lokesha L N

  • The only thing here  -  "Quick repair and rebuild" is not enough. In my case I had  to delete everything inside cache directory manually.

  • This article can help you.

    André Lopes
    Lampada Global
    Skype: andre.lampada