AnsweredAssumed Answered

is the usage of "visibility_grid" possible in searchdefs?

Question asked by Docugroup Insignio on May 20, 2016

In the searchview of call module I want to build a dependency between two dropdown lists.

The option values of list "call_type_class_c" (custom field) are supposed to dependent on whatever is selected in list "name".

 

In \custom\Extension\modules\Calls\Ext\Vardefs\sugarfield_call_type_class_c.php

 

there are visibility_grid definitions that are in use already for the edit view and which are working there:

 

<?php

$dictionary['Call']['fields']['call_type_class_c']['labelValue']='Klassifizierung';

$dictionary['Call']['fields']['call_type_class_c']['visibility_grid']=array (

  'trigger' => 'name',

  'values' =>

  array (

    1 =>

    array (

      0 => '',

      1 => '1001',

      2 => '9999',

    ),

    2 =>

      array(

      0 => '',

      1 => '21',

      2 => '22',

      3 => '23',

      ),

  ),

); 

 

 

I copied that part to \custom\modules\Calls\metadata\searchdefs.php which now looks like this:

 

 

<?php

$searchdefs['Calls'] =

    array(

        'layout' =>

            array(

                'basic_search' => array(),//does not matter

                'advanced_search' =>

                    array(

                        'name' =>

                            array(

                                'name' => 'name',

                                'default' => true,

                                'width' => '10%',

                                'displayParams' => array(

                                    'size' => 1,

                                    'javascript' => 'onchange="somefunction();"',

                                ),

                            ),

                        'call_type_class_c' =>

                            array(

                                'name' => 'call_type_class_c',

                                'type' => 'enum',

                                'label' => 'LBL_CALL_TYPE_CLASS_C',

                                'width' => '10%',

                                'displayParams' => array(

                                    'size' => 1,

                                ),

                                'visibility_grid' => array(

                                    'trigger' => 'name',

                                    'values' =>

                                        array(

                                            1 =>

                                                array(

                                                    0 => '',

                                                    1 => '1001',

                                                    2 => '9999',

                                                ),

                                            2 =>

                                                array(

                                                    0 => '',

                                                    1 => '21',

                                                    2 => '22',

                                                    3 => '23',

                                                ),

                                        ),

                                ),

                            ),

                    ),

            ),

        'templateMeta' =>

            array(

                'maxColumns' => '3',

                'maxColumnsBasic' => '4',

                'widths' =>

                    array(

                        'label' => '10',

                        'field' => '30',

                    ),

            ),

    );

 

One of the possible reasons that this does not work may be, that Sugar changes the IDs for the list elements from "name" to "name_advanced"

and from "call_type_class_c_" to "call_type_class_c_advanced". Changing the trigger parameter to "name_advanced" is no help though.

 

Any ideas? Is visibility_grid a possible way to do this or do I need some custom javascript, e.g. using "somefunction()" in displayParams ?

Outcomes