[Vtigercrm-developers] vtlib adding a picklist field

Manu urs manu.k at vtiger.com
Tue Jul 28 12:57:56 GMT 2015


Hi

There may be a duplicate  values you are trying to insert into the
table.The below code may help you , Please check it.

include_once 'include/utils/utils.php';
> include_once 'vtlib/Vtiger/Module.php';
> require_once 'includes/Loader.php';
>
> $proInstance = Vtiger_Module_Model::getInstance('Leads');
> if($proInstance){
> $fieldInstance = Vtiger_Field_Model::getInstance('Leads', $proInstance);
>    if ($proInstance !== false && !$fieldInstance) {
>
>        $blockInstance = new Vtiger_Block();
>        $blockInstance->label = 'LBL_TEST_PICKLIST';
>        $proInstance->addBlock($blockInstance);
>        $field  = new Vtiger_Field();
>        $field->name        = 'test_picklist_field';
>        $field->label       = 'Test Picklist Field';
>        $field->uitype      = 16;
>        $field->typeofdata  = 'I~O';
>
>        $field->setPicklistValues( Array ('Value1', 'Value2') );
>        $blockInstance->addField($field);
>        echo "<br>Picklist of UItype 16 is added to contact";
>    }
> }
>


Regards,
Manu Urs


On Tue, Jul 28, 2015 at 5:27 PM, Kevin Alderton <
lists.k.j.alderton at gmail.com> wrote:

>  Hi,
>
> In the vtiger logs I am getting the following:
>
> INFO VT - PearDatabase ->ADODB error  Query Failed:INSERT INTO
> vtiger_testpicklist (testpicklist id, testpicklist , sortorderid, presence)
> VALUES(?,?,?,?)::->[1064]You have an error in your SQL syntax; check the
> manual that corresponds to your MySQL server version for the right syntax
> to use near 'id, testpicklist , sortorderid, presence)
> VALUES(0,'Value2',2,1)' at line 1
>
>  Is this a bug???????
>
>
>
>
>
>
>
>
> Hello,
>
> I am having trouble with vtlib and vtiger 6.3.
>
> I am trying to add a picklist field in the Leads module.
>
> All is well except no values are stored in the database nor table
> inserted.  Having tried three new instances of vtiger I am now wondering if
> there has been an alteration in vtlib for 6.x.  It maybe something that I
> am missing.  Has anyone had anything similar?
>
> My code is:
>
> <?php
>
> include_once('vtlib/Vtiger/Module.php');
> include_once('vtlib/Vtiger/Utils.php');
>
> $module = Vtiger_Module::getInstance('Leads');
>
> $blockInstance =  new vtiger_block();
>
> $blockInstance->label = 'LBL_TEST_PICKLIST';
> $module ->addBlock($blockInstance);
>
> $fieldInstance = new Vtiger_Field();
> $fieldInstance->name = 'test_picklist_field ';
> $fieldInstance->label = 'Test Picklist Field';
> $fieldInstance->column = 'test_picklist_field';
> $fieldInstance->columntype = 'VARCHAR(50)';
> $fieldInstance-> table =  $module->basetable;
> $fieldInstance->uitype = 16;
> $fieldInstance->typeofdata = 'V~O';
> $blockInstance->addField($fieldInstance);
> echo "Added field <br />";
> $fieldInstance->setPicklistValues( Array ('Value1', 'Value2') );
>
> Tia
>
>
> _______________________________________________
> http://www.vtiger.com/
>



-- 
Regards,
Manu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20150728/da5d8936/attachment.html>


More information about the vtigercrm-developers mailing list