Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create a second 'related user' field in a module
#1
Can I define a second 'related to user' field (UI type 53) in a module? Obviously not writing to the same column as 'assigned_user_id' but really as a normal module field.
Reply
#2
you have to use uitype 101, there can only be one uitype 53 on a module, and there can only be one 101 also and it has to be defined like this:

https://github.com/tsolucio/corebos/blob/master/modules/CobroPago/manifest.xml#L456

I thnk the fieldname is important
Joe
TSolucio
Reply
#3
Ah, Okay. In that case I will be kind of abusing this field, as I want to use it not to enter the user that needs to be reported to, but the user that is going to execute a certain salesorder in the field. But, at least I have the possibility to use this field.
Reply
#4
It is just a name, so no problem. In fact we use it on the Payment module to indicate the sales person or responsable user of the payment
Joe
TSolucio
Reply
#5
Ah, great. So I can use the field the way I have in mind. I'll write a little story on how I think I want to want my portal project to work as soon as I have all the info / testing I need.
Reply
#6
I tried the following code to add a "101" field to SalesOrder:

PHP Code:
include_once('vtlib/Vtiger/Module.php');

$module Vtiger_Module::getInstance('SalesOrder');
$blockInstance Vtiger_Block::getInstance('LBL_SO_INFORMATION'$module);

$fieldInstance = new Vtiger_Field();
$fieldInstance->name 'reports_to_id';
$fieldInstance->table 'vtiger_salesorder';
$fieldInstance->column 'executing_user_id';
$fieldInstance->columntype 'INT(11)';
$fieldInstance->uitype 101;
$fieldInstance->typeofdata 'V~O';
$blockInstance->addField($fieldInstance); 

This worked, but gave me the following error:

PHP Code:
Catchable fatal errorObject of class Vtiger_Module could not be converted to string in index.php on line 687 

Does anyone know what went wrong? As said, the field was created.
Reply
#7
What code is on that line? In a stock coreBOS there is just some CSS:

https://github.com/tsolucio/corebos/blob/master/index.php#L687

A few lines above there is $module=='Events', have you added some code there that assigns a Vtiger_Module to that variable?
Joe
TSolucio
Reply
#8
The code on that line is:

PHP Code:
        preg_match("/^AddBlockFieldToDB/"$action) || 

I remember something happened: my PC crashed when this file was open in sublime text (I sometimes set the error reporting here for debugging). Now the entire file is double-spaced.. So I'll replace it with a stock one and see what happens.

Apart from that: what is the best way to delete a field? This way I can do some repeated tests and see if this is solved.
Reply
#9
That line looks correct. Let me know how it goes.


To delete the field use the delete method


PHP Code:
$field Vtiger_Field::getInstance('your_field_name',$moduleInstance);
$field->delete(); 
Joe
TSolucio
Reply
#10
Well, I've included that code in my postinstall, uninstalled and re-installed my module and the field is created. The install finishes without any issues. I'll update my code so that the correct removal methods for the field is implemented in the post uninstall.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)