[Vtigercrm-developers] Initialize fields when I created a new record

enrico manna enrico.manna at web2e.it
Fri Oct 27 11:25:36 GMT 2017


Hi all,

When I created a new record in my custom module  I can initialize the
fields with method: getCleanInstance

In the example bellow I initialized the filed [1]  customnamefield  with a
default value.

The second field [2], for example account, is composed by id and display
(select field),
in this case I don't understand how initialize the display value [2B].

-----------------------------------------------
    public static function getCleanInstance($moduleName) {

        $focus = CRMEntity::getInstance($moduleName);
        $modelClassName = Vtiger_Loader::getComponentClassName('Model',
'Record', $moduleName);
        $instance = new $modelClassName();
        $recordModel =
$instance->setData($focus->column_fields)->setModule($moduleName)->setEntity($focus);

        // [1] Normal text input
        $fieldName = "customnamefield";
        $recordModel->set($fieldName, 'this is default value');


        //[2A] related field
        $fieldName = "accountid";
        $recordModel->setData($fieldName, '1');

         //[2B] related field display value  - WRONG
        $fieldName = "accountid_display";
        $recordModel->setData($fieldName, 'Account name');


        return $recordModel;

    }

Can  someone help me how I can initialize different type of filelds ?
-- 

*Enrico Manna*
*Web2e - Strategie per il web*

Web: http://www.web2e.it
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20171027/f1a6a239/attachment.html>


More information about the vtigercrm-developers mailing list