how to define relate field lookup value working in the modules

I took the following sample off Cases module and tried to apply same pattern but it is not working for me

'site_mxxn' => array(
'name' => 'site_mxxn',
'rname' => 'name',
'id_name' => 'site_id',
'vname' => 'LBL_SITE_MXXN',
'type' => 'relate',
'related_fields' => array(
'site_id',
),
'link' => 'accounts_workorder_1',
'table' => 'accounts_cstm', //--> THE COLUMN I NEED TO DISPLAY ON FRONTEND IS ON THIS TABLE CALLED MXXN
'join_name' => 'accounts',
'isnull' => 'true',
'module' => 'CustomAccount',
'dbType' => 'varchar',
'len' => 100,
'source' => 'non-db',
'unified_search' => true,
'comment' => 'The name of the site represented by the site_id field',
'required' => true,
'importable' => 'required',
'exportable' => true,
'studio' => array(
'portalrecordview' => false,
'portallistview' => false,
),
),
'site_id' => array(
'name' => 'site_id',
'type' => 'relate',
'dbType' => 'id',
'rname' => 'id',
'module' => 'CustomAccounts',
'id_name' => 'site_id',
'reportable' => false,
'vname' => 'LBL_SITE_ID',
'audited' => true,
'massupdate' => false,
'comment' => 'The site to which the order is associated',
),


I keep getting an error when I try to save the record



PHP Fatal error:  Uncaught Error: Call to a member function getOwnerField() on null in /var/www/html/include/SugarQuery/Builder/Field/Select.php:117\nStack trace:\n#0 /var/www/html/include/SugarQuery/Builder/Field.php(112): SugarQuery_Builder_Field_Select->expandField()\n#1 /var/www/html/include/SugarQuery/Builder/Field.php(87): SugarQuery_Builder_Field->setupField(Object(SugarQuery))\n#2 /var/www/html/include/SugarQuery/Builder/Field/Select.php(23): SugarQuery_Builder_Field->__construct('site_mxxn', Object(SugarQuery))\n#3 /var/www/html/include/SugarQuery/Builder/Select.php(53): SugarQuery_Builder_Field_Select->__construct('site_mxxn', Object(SugarQuery))\n#4 /var/www/html/include/SugarQuery/SugarQuery.php(205): SugarQuery_Builder_Select->field(Array)\n#5 /var/www/html/data/SugarBean.php(3505): SugarQuery->select(Array)\n#6 /var/www/html/clients/base/api/FilterApi.php(712): SugarBean->fetchFromQuery(Object(SugarQuery), Array, Array)\n#7 /var/www/html/clients/base/api/FilterApi.php(445): FilterApi->runQuery(Object(RestService), Array,  in /var/www/html/include/SugarQuery/Builder/Field/Select.php on line 117, referer: http://localhost/

I have 2 custom modules, ORDER 1:->M SITE

I want to create a lookup field on ORDER related to SITE so when on record view for order I want to type in site name and be able to select it from dropdown list and save in db for ORDER

SITE extends the accounts module

a site can have many orders

Parents Reply Children
No Data