AnsweredAssumed Answered

Fill Dropdown from a database 6.5.24

Question asked by Lance Devin on Oct 7, 2016
Latest reply on Oct 10, 2016 by Lance Devin

Sugar Version: 6.5.24

Database: MS SQL Server

deployment: Onsite

IIS 7.x

PHP: 5.4.24

 

I have created a vardef override in
..\custom\Extension\modules\<MODULE>\Ext\Vardefs\sugarfield_custom_receptacles.php and it has these two lines that override the field receptacle_type_4 which is a dropdown field.

       unset($dictionary['ccfg_Cabconfig']['fields']['receptacle_type_4']['options']);
      $dictionary['ccfg_Cabconfig']['fields']['receptacle_type_4']['function'] = 'getReceptacleTypes';

 

I created the global function getReceptacleTypes in

..\custom\include\custom_utils.php

 

custom_utils for simplicity is stubbed to be

<?php

function getReceptacleTypes() {

   static $list = null;

   <bunch of commented out code to get stuff from db>

   return $list;

}

 

This basically gives me a 500 error in IIS.  Obviously, I'm either approaching this wrong (but I've referred to these two articles)

https://developer.sugarcrm.com/2011/04/13/howto-populate-enum-values-from-a-database-table/ 

https://developer.sugarcrm.com/2011/08/24/howto-have-a-dropdown-field-that-gets-its-options-from-a-function/ 

 

or Sugar 6.5.24 doesn't support this.

 

Either way, if anybody could help I would be highly appreciative and will drink a beer in your honor.  Thank you in advance.

Outcomes