<div dir="ltr"><div><div><br></div><div>ok, I solved it ...</div></div><div>It's correct also for related fields use this code:</div><div><br></div><div><div style="font-size:12.8px">        $fieldName = "accountid";<br></div><div style="font-size:12.8px">        $recordModel->setData($<wbr>fieldName, '1');      </div></div><div><br></div><div>in this case the value of display is set.</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-10-27 13:25 GMT+02:00 enrico manna <span dir="ltr"><<a href="mailto:enrico.manna@web2e.it" target="_blank">enrico.manna@web2e.it</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>When I created a new record in my custom module  I can initialize the fields with method: getCleanInstance</div><div><br></div><div>In the example bellow I initialized the filed [1]  customnamefield  with a default value.</div><div><br></div><div>The second field [2], for example account, is composed by id and display (select field),</div><div>in this case I don't understand how initialize the display value [2B].</div><div><br></div><div>------------------------------<wbr>-----------------</div><div><div>    public static function getCleanInstance($moduleName) {</div><div><br></div><div>        $focus = CRMEntity::getInstance($<wbr>moduleName);</div><div>        $modelClassName = Vtiger_Loader::<wbr>getComponentClassName('Model', 'Record', $moduleName);</div><div>        $instance = new $modelClassName();</div><div>        $recordModel =  $instance->setData($focus-><wbr>column_fields)->setModule($<wbr>moduleName)->setEntity($focus)<wbr>;</div><div><br></div><div>        // [1] Normal text input</div><div>        $fieldName = "customnamefield";<br></div><div>        $recordModel->set($fieldName, 'this is default value');</div><div><br></div><div>      <br></div><div>        //[2A] related field </div><div>        $fieldName = "accountid";<br></div><div>        $recordModel->setData($<wbr>fieldName, '1');         </div><div><br></div><div>         //[2B] related field display value  - WRONG</div><div>        $fieldName = "accountid_display";<br></div><div>        $recordModel->setData($<wbr>fieldName, 'Account name');            </div><div><br></div><div>        </div><div>        return $recordModel;</div><div>        </div><div>    }</div><div><br></div><div>Can  someone help me how I can initialize different type of filelds ?<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888">-- <br><div class="m_1837549354529740749gmail_signature"><div dir="ltr"><div style="font-size:small"><b><br>Enrico Manna</b></div><div style="font-size:small"><i>Web2e - Strategie per il web</i></div><div style="font-size:small"><br></div><div style="font-size:small">Web: <a href="http://www.web2e.it" style="color:rgb(17,85,204)" target="_blank">http://www.web2e.it</a></div><div style="font-size:small"><br></div><div style="font-size:small"><br></div><div><br></div></div></div>
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div style="font-size:small"><b><br>Enrico Manna</b></div><div style="font-size:small"><i>Web2e - Strategie per il web</i></div><div style="font-size:small"><br></div><div style="font-size:small">Tel: 02 3654 3268</div><div style="font-size:small">Cell: 340 9325624 <br></div><div style="font-size:small">Email: <a href="mailto:enrico.manna@web2e.it" style="color:rgb(17,85,204)" target="_blank">enrico.manna@web2e.it</a></div><div style="font-size:small">Skype: webem_enrico</div><div style="font-size:small">Web: <a href="http://www.web2e.it" style="color:rgb(17,85,204)" target="_blank">http://www.web2e.it</a></div><div style="font-size:small">Linkedin: <a href="http://it.linkedin.com/in/enricomanna/" style="color:rgb(17,85,204)" target="_blank">it.linkedin.com/in/enricomanna/</a><br></div><div style="font-size:small"><br></div><div><br></div></div></div>
</div>