<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div name="messageBodySection">
<div dir="auto">I was missing the default value and setPicklistValues. I’ll try this out maybe the version we use has bugs...</div>
</div>
<div name="messageSignatureSection"><br />
<div class="matchFont"><font color="#C6C6C6"><b><span style="">Sukhdev Mohan</span></b></font><span style=""></span><br />
<font color="#999999"><b><span style="">Developer</span></b></font><br /></div>
</div>
<div name="messageReplySection">
<div dir="auto">On 15 Mar 2022, 10:29 +0100, Alan Lord <alanslists@gmail.com>, wrote:</div>
<blockquote style="border-left-color: rgb(26, 188, 156); margin: 5px; padding-left: 10px; border-left-width: thin; border-left-style: solid;">On 15/03/2022 08:58, Sukhdev Mohan wrote:<br />
<blockquote style="border-left-color: rgb(230, 126, 34); margin: 5px; padding-left: 10px; border-left-width: thin; border-left-style: solid;">Thanks Alan, you're always a very good point for resources!<br />
<br />
I recently had to create a uitype 16 (non based picklist) through vtlib,<br />
it seemingly created the field but when I tried to add values from admin<br />
menu it resulted in error. Checking the DB there were some tables<br />
missing and even if I added them manually the field didn't work. Had to<br />
create a custom picklist from layout and that worked. Something for<br />
uitype 15. So the question is what's the right procedure?</blockquote>
<br />
This works for me:<br />
<br />
<blockquote style="border-left-color: rgb(230, 126, 34); margin: 5px; padding-left: 10px; border-left-width: thin; border-left-style: solid;">$module = Vtiger_Module::getInstance('LSSvcPNW');<br />
$block_svcd = Vtiger_Block::getInstance('Satellite', $module);<br />
$table = 'ls_svcs_pnw'; > $picklist_array = array("New Service", "Upgrade", "Downgrade",</blockquote>
"Reactivation", "Suspension", "Termination");<br />
<br />
<blockquote style="border-left-color: rgb(230, 126, 34); margin: 5px; padding-left: 10px; border-left-width: thin; border-left-style: solid;">$field = new Vtiger_Field();<br />
$field->name = 'lssvc_svctype';<br />
$field->column = $field->name;<br />
$field->label = 'Service Type';<br />
$field->table = $table;<br />
$field->columntype = 'VARCHAR(255)';<br />
$field->uitype = 15;<br />
$field->typeofdata = 'V~O';<br />
$field->defaultvalue = 'New Service';<br />
$field->summaryfield = 1;<br />
$block_svcd->addField($field);<br />
$field->setPicklistValues($picklist_array);<br />
unset($field, $picklist_array);</blockquote>
<br />
<br />
Some field values are optional obviously.<br />
<br />
<br />
HTH<br />
<br />
Al<br />
<br />
_______________________________________________<br />
http://www.vtiger.com/</blockquote>
</div>
</body>
</html>