Here is the situation, I'm trying to get the Serialized Inventory Item based on the id (https://xxx.app.netsuite.com/app/common/item/item.nl?id=522216), however, when I tried the following code:
$search = new TransactionSearchBasic();
$type = new SearchEnumMultiSelectField();
$type->operator = 'anyOf';
$type->searchValue = array('serializedInventoryItem');
$search->type = $type;
$invetoryRef = new RecordRef();
$invetoryRef->internalId = '522216';
$params = new SearchMultiSelectField();
$params->operator = 'anyOf';
$params->searchValue = array($invetoryRef);
$search->serializedInventoryItem = $params;
$request = new SearchRequest();
$request->searchRecord = $search;
$searchResponse = $service->search($request);
However, the response that I'm getting the following error:
The field type's enum value is invalid for this search.
Why would I be getting that error message?
Thank you,
Kevin Davis
I am trying to use SoapClient in PHP to retrieve data from a WSDL. If I use hardcoded values, then it works with zero errors:
$client = new SoapClient(someWSDLUrl);
$params2 = array();
$params2['AuthenticationKey'] = $obj->{'LoginResult'};
$params2['VehicleClass'] = 'UsedCar';
$params2['ApplicationCategory'] = 'Consumer';
$params2['VersionDate'] = '2016';
$result2 = $client->GetMakes($params2);
I am getting the following error when I use variables or dynamic content:
Fatal error: Uncaught SoapFault exception: [a:DeserializationFailed
] The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter
http://someURL/VehicleInformationService:VehicleClass
. The InnerException message was 'Invalid enum value 'UsedCars'
I have tried
$client = new SoapClient(someWSDLUrl);
$params2 = array();
$params2['AuthenticationKey'] = $obj->{'LoginResult'};
$params2['VehicleClass'] = $VehicleClass;
$params2['ApplicationCategory'] = $ApplicationCategory;
$params2['VersionDate'] = $VersionDate;
$result2 = $client->GetMakes($params2);
I have also tried
$client = new SoapClient(someWSDLUrl);
$params2 = array();
$params2['AuthenticationKey'] = (string) $obj->{'LoginResult'};
$params2['VehicleClass'] = (string) $VehicleClass;
$params2['ApplicationCategory'] = (string) $ApplicationCategory;
$params2['VersionDate'] = (string) $VersionDate;
$result2 = $client->GetMakes($params2);
I have also tried:
$SubmitData = new stdClass();
$SubmitData->AuthenticationKey = new SoapVar($obj->{'LoginResult'}, XSD_STRING);
$SubmitData->VehicleClass = new SoapVar($VehicleClass, XSD_STRING);
$SubmitData->ApplicationCategory = new SoapVar($ApplicationCategory, XSD_STRING);
$SubmitData->VersionDate = new SoapVar($VersionDate, XSD_STRING);
$result2 = $client->GetMakes($SubmitData);
Same error each time. I do not know how to get around "Invalid enum value" error
Thanks in advance
For some reason, my code is generating module=undefined:
/index.php?module=undefined&action=Popup&html=Popup_picker&form=vtlibPopupView&forfield=Quotes&srcmodule=Leads&forrecord=1695
The problem is that I define the module directly in my script:
$field0->setRelatedModules(Array('Quotes'));
What am I doing wrong here?
Here's my complete code:
$Vtiger_Utils_Log = true;
include_once('vtlib/Vtiger/Menu.php');
include_once('vtlib/Vtiger/Module.php');
//(module name without space)
$module = Vtiger_Module::getInstance('Leads');
$module->initWebservice();
// Create Block instance
$block1 = new Vtiger_Block();
$block1 = Vtiger_Block::getInstance('LBL_LEAD_INFORMATION', $module);
$field0 = new Vtiger_Field();
$field0->name = 'quotes';
$field0->column = 'quotes';
$field0->label = 'Test2';
$field0->uitype = 10;
$field0->typeofdata = 'V~O';
//$field0->setRelatedModules(Array('Quotes'));
$field0->setRelatedModules(Array('quotes'));
$block1->addField($field0);
You have to set related module after adding the field. You can't set relation to any module before adding field.
Add the code below to the addField line.
$block1->addField($field0);
$field0->setRelatedModules(Array('Quotes'));
And also i think you have to add field to table the lead table.
So update your code like this.
$field0 = new Vtiger_Field();
$field0->name = 'quotes';
$field0->column = 'quotes';
$field0->table = $module->basetable;
$field0->label = 'Test2';
$field0->uitype = 10;
$field0->typeofdata = 'V~O';
$block1->addField($field0);
$field0->setRelatedModules(Array('Quotes'));
I am new to Vtiger CRM and I have searched a lot to find how to create a custom module in Vtiger CRM with a table associated with it from scratch. I am not able to follow the documentation provided by Vtiger.
Refer this url for Creating New module and fields.
https://wiki.vtiger.com/index.php/CreatingEntityModule
Or if you having any problem then follow as per instructions.
first of all do this.
First create a new folder(module name without space) in modules and copy files from vtlib/ModuleDir/5.4.0 file to the folder created in modules/newmodule
Change name of ModuleFile.js, ModuleFile.php, ModuleFileAjax.php with your module name(with no space).
Keep in mind, During changing name of ModuleFileAjax.php just Replace ModuleFile with name of Module.
Go to modulename.php to change the class name, $table_name (6values change), $table_index (4values change).
Create new file with any name. Insert the code below to add the fields and also module.
<?php
// Turn on debugging level
$Vtiger_Utils_Log = true;
include_once('vtlib/Vtiger/Menu.php');
include_once('vtlib/Vtiger/Module.php');
$module = new Vtiger_Module();
$module->name = 'Store';//(No space in module name)
$module->save();
$module->initTables();
$module->initWebservice();
$menu = Vtiger_Menu::getInstance('Support');
$menu->addModule($module);
$block1 = new Vtiger_Block();
$block1->label = 'Organization Information';
$module->addBlock($block1); //to create a new block
$field0 = new Vtiger_Field();
$field0->name = 'organization_name';
$field0->label = 'Organization Name';
$field0->table = $module->basetable;
$field0->column = 'organization_name';
$field0->columntype = 'VARCHAR(100)';
$field0->uitype = 2;
$field0->typeofdata = 'V~M';
$module->setEntityIdentifier($field0); //to insert values in entity folder
$block1->addField($field0); //to add field in block
$field1 = new Vtiger_Field();
$field1->name = 'store_id_auto';
$field1->label = 'Store ID';
$field1->table = $module->basetable;
$field1->column = 'store_id_auto';
$field1->columntype = 'VARCHAR(100)';
$field1->uitype = 4;
$field1->typeofdata = 'V~O';
$block1->addField($field1);
//Do not change any value for filed2.
$field2 = new Vtiger_Field();
$field2->name = 'assigned_user_id';
$field2->label = 'Assigned To';
$field2->table = 'vtiger_crmentity';
$field2->column = 'smownerid';
$field2->columntype = 'int(19)';
$field2->uitype = 53;
$field2->typeofdata = 'V~M';
$block1->addField($field2);
$filter1 = new Vtiger_Filter();
$filter1->name = 'All';
$filter1->isdefault = true;
$module->addFilter($filter1);
// Add fields to the filter created
$filter1->addField($field0, 1);
$filter1->addField($field1, 2);
$filter1->addField($field2, 3);
/** Set sharing access of this module */
$module->setDefaultSharing('Private');
/** Enable and Disable available tools */
$module->enableTools(Array('Import', 'Export'));
$module->disableTools('Merge');
?>
we have Create Store module
Create folder in modules/Store and also create Store.php file in Store folder
modules/Store/Store.php
include_once 'modules/Vtiger/CRMEntity.php';
class Store extends Vtiger_CRMEntity {
var $table_name = 'vtiger_store';
var $table_index= 'storeid';
var $customFieldTable = Array('vtiger_storecf', 'storeid');
var $tab_name = Array('vtiger_crmentity', 'vtiger_store', 'vtiger_storecf');
var $tab_name_index = Array(
'vtiger_crmentity' => 'crmid',
'vtiger_store' => 'storeid',
'vtiger_storecf'=>'storeid');
var $list_fields = Array (
/* Format: Field Label => Array(tablename, columnname) */
// tablename should not have prefix 'vtiger_'
'Organization Name' => Array('store', 'organization_name'),
'Assigned To' => Array('crmentity','smownerid')
);
var $list_fields_name = Array (
/* Format: Field Label => fieldname */
'Organization Name' => 'organization_name',
'Assigned To' => 'assigned_user_id',
);
// Make the field link to detail view
var $list_link_field = 'organization_name';
// For Popup listview and UI type support
var $search_fields = Array(
/* Format: Field Label => Array(tablename, columnname) */
// tablename should not have prefix 'vtiger_'
'Organization Name' => Array('store', 'organization_name'),
'Assigned To' => Array('vtiger_crmentity','assigned_user_id'),
);
var $search_fields_name = Array (
/* Format: Field Label => fieldname */
'Organization Name' => 'organization_name',
'Assigned To' => 'assigned_user_id',
);
// For Popup window record selection
var $popup_fields = Array ('organization_name');
// For Alphabetical search
var $def_basicsearch_col = 'organization_name';
// Column value to use on detail view record text display
var $def_detailview_recname = 'organization_name';
// Used when enabling/disabling the mandatory fields for the module.
// Refers to vtiger_field.fieldname values.
var $mandatory_fields = Array('organization_name','assigned_user_id');
var $default_order_by = 'organization_name';
var $default_sort_order='ASC';
}
Create languages/en_us/Store.php
<?php
$languageStrings = array(
'SINGLE_Store'=>'Store'
);
?>
Create file /var/www/html/Projectname/Store.php and run this file
<?php
// Turn on debugging level
$Vtiger_Utils_Log = true;
include_once('vtlib/Vtiger/Menu.php');
include_once('vtlib/Vtiger/Module.php');
$module = new Vtiger_Module();
$module->name = 'Store';//(No space in module name)
$module->save();
$module->initTables();
$module->initWebservice();
$menu = Vtiger_Menu::getInstance('Support');
$menu->addModule($module);
$block1 = new Vtiger_Block();
$block1->label = 'Organization Information';
$module->addBlock($block1); //to create a new block
$field0 = new Vtiger_Field();
$field0->name = 'organization_name';
$field0->label = 'Organization Name';
$field0->table = $module->basetable;
$field0->column = 'organization_name';
$field0->columntype = 'VARCHAR(100)';
$field0->uitype = 2;
$field0->typeofdata = 'V~M';
$module->setEntityIdentifier($field0); //to insert values in entity folder
$block1->addField($field0); //to add field in block
$field1 = new Vtiger_Field();
$field1->name = 'store_id_auto';
$field1->label = 'Store ID';
$field1->table = $module->basetable;
$field1->column = 'store_id_auto';
$field1->columntype = 'VARCHAR(100)';
$field1->uitype = 4;
$field1->typeofdata = 'V~O';
$block1->addField($field1);
//Do not change any value for filed2.
$field2 = new Vtiger_Field();
$field2->name = 'assigned_user_id';
$field2->label = 'Assigned To';
$field2->table = 'vtiger_crmentity';
$field2->column = 'smownerid';
$field2->columntype = 'int(19)';
$field2->uitype = 53;
$field2->typeofdata = 'V~M';
$block1->addField($field2);
$field3 = new Vtiger_Field();
$field3->name = 'CreatedTime';
$field3->label= 'Created Time';
$field3->table = 'vtiger_crmentity';
$field3->column = 'createdtime';
$field3->uitype = 70;
$field3->typeofdata = 'T~O';
$field3->displaytype= 2;
$block->addField($field3);
$field4 = new Vtiger_Field();
$field4->name = 'ModifiedTime';
$field4->label= 'Modified Time';
$field4->table = 'vtiger_crmentity';
$field4->column = 'modifiedtime';
$field4->uitype = 70;
$field4->typeofdata = 'T~O';
$field4->displaytype= 2;
$block->addField($field4);
$filter1 = new Vtiger_Filter();
$filter1->name = 'All';
$filter1->isdefault = true;
$module->addFilter($filter1);
// Add fields to the filter created
$filter1->addField($field0, 1);
$filter1->addField($field1, 2);
$filter1->addField($field2, 3);
/** Set sharing access of this module */
$module->setDefaultSharing('Private');
/** Enable and Disable available tools */
$module->enableTools(Array('Import', 'Export'));
$module->disableTools('Merge');
?>
I want to add new field to vtiger_activity table in vtiger crm. I added the column in the table but now I am not getting place from where the insert function is called, and also how to add this new field to the column list through php code.
thanks
You can add field from module setting-> Layout Editor-> Add Custom Filed Or if you want to add field by using code then here below is the code.
<?php
$Vtiger_Utils_Log = true;
include_once('vtlib/Vtiger/Menu.php');
include_once('vtlib/Vtiger/Module.php');
//(module name without space)
$module = new Vtiger_Module();
$module->name = 'Modulename';
$module = $module->getInstance('Modulename');
// Create Block instance
$block1 = new Vtiger_Block();
$block1->label = 'Block Name';
$block1 = $block1->getInstance($block1->label,$module);
$field0 = new Vtiger_Field();
$field0->name = 'field name';
$field0->table = $module->basetable;
$field0->label = 'Field Name to display';
$field0->column = 'field name';
$field0->columntype = 'VARCHAR(100)';
$field0->uitype = 2;
$field0->typeofdata = 'V~O';
$block1->addField($field0);
?>