CoreBOSBB
A VTLIB way to add values to an existing picklist - Printable Version

+- CoreBOSBB (https://discussions.corebos.org)
+-- Forum: Development (https://discussions.corebos.org/forumdisplay.php?fid=18)
+--- Forum: coreBOS Development (https://discussions.corebos.org/forumdisplay.php?fid=4)
+--- Thread: A VTLIB way to add values to an existing picklist (/showthread.php?tid=656)



A VTLIB way to add values to an existing picklist - Guido1982 - 05-17-2017

I'm updating one of my modules, and I'd like to add some values to one of the picklists. Is that as simple as:

PHP Code:
            // Setup the field
            
$invoicePaymentCondField                =    new Vtiger_Field();
            
$invoicePaymentCondField->name            =    'existing_name';
            
$invoicePaymentCondField->label            =    'Label';
            
$invoicePaymentCondField->table            =    'existing_table';
            
$invoicePaymentCondField->column        =    'existing column';
            
$invoicePaymentCondField->columntype    =    'VARCHAR(100)';
            
$invoicePaymentCondField->uitype        =    16;
            
$invoicePaymentCondField->typeofdata    =    'V~M';
            
$invoiceDescriptionBlock->addField($invoicePaymentCondField);        
            
            
$invoicePaymentCondField->setPicklistValues( array('Existing values with new values') ); 

Or is there a special method for this?


RE: A VTLIB way to add values to an existing picklist - joebordes - 05-17-2017

You have to use setPicklistValues() method.:

You get a reference to the field:
https://github.com/tsolucio/corebos/blob/master/build/changeSets/DefineGlobalVariables.php#L256

and then call the method with the list of values in an array:
https://github.com/tsolucio/corebos/blob/master/build/changeSets/DefineGlobalVariables.php#L296

vtlib will not repeat any existing values


RE: A VTLIB way to add values to an existing picklist - Guido1982 - 05-17-2017

Thanks! Repeat any existing values, you mean I need to repopulate the entire list of values, not just add new ones?


RE: A VTLIB way to add values to an existing picklist - joebordes - 05-17-2017

Sorry, I mean that if you try to put in a value that already exists it is simply ignored. vtiger CRM repeated the value.
In other, words you can send in the array with the values, all values that are not already present will be added.