[RELEASE] CustomFields module

Forgot to update the news here, but Toomanylogin’s problem was fixed a while ago.

It came from an include_once() which was called multiple times in CustomFields when multicompany was enabled. Changed to include() and everything’s fine.

This bug is fixed since CustomFields Free v2.13, so that CustomFields Free and Pro are both compatible with Multicompany module and Joomla link module too.

Hello,

I have noticed a couple of bugs in latest pro version.

  1. If you create a custom field of type Area box and attempt to set the default value in CustomFields module setup to a large number of words for example 500. An error is generated and the field cannot be created. I’m trying to automatically insert description to include in ODT files.

  2. If you create custom field of type area box then display the field and enter data. You can enter a large amount of data 500 words but on the save all line breaks are stripped. If you display the custom field there are no line breaks. If you include custom field in ODT there are no line breaks.

  3. If you create a custom field on the project table and also a custom field on the tasks table. Go to project add a task in the new task panel you will see the project field is displayed. If you save the new task and reopen to modify you can see the task field.

Regards
Paul

Overloading Functions. I am struggling to get this to work has anybody tried it.

I am trying to lookup data from two joomla tables, categories and templates. I have created two CustomFields on the tasks table note_title which is constrained on the joomla category table and title which is constrained on the templates table. I’m trying to insert the data entered project task.

In the project task card I get a drop down box of categories. When I select a category I then want to show the template names for that category in a second drop-down box. I have edited the customfields_fields_extend.lib as follows.

can anybody spot the mistake ?

Thanks
Paul

[code]
function customfields_field_editview_projecttaskcard_title (&$currentmodule, &$object, &$parameters, &$action, &$user, &$idvar, &$rightok, &$customfields, &$field, &$name, &$value) {
global $db; // allow to access database functions
$sql=“SELECT note_title, title, rowid FROM doli_project_task_customfields INNER JOIN j25_n3ttemplate_categories ON doli_project_task_customfields.note_title = j25_n3ttemplate_templates.category_id WHERE doli_project_task_customfields.fk_project_task=”.$object->id;
$result=$db->query($sql);

if ($result) {
$num = $db->num_rows($result);
$i = 0;
$myarray = array();
while ($i < $num)
{
$obj = $db->fetch_object($result);
$myarray []=array(‘id’=>$obj->rowid, ‘value’=>$obj->title);
$i++;
}
$value = $myarray;
$db->free($result);
}
}[/code]

Hello Paul,

About the bugs:

  1. It’s not possible to specify a size for Areabox types because they rely on the SQL text() type, which itself can’t specify a size because it’s a variable-sized type, which mean that you don’t have to care about the size of your input, SQL will automatically manage it. On the other hand, Textbox type (which rely on varchar2()) can be sized as you like, but it won’t be resized automatically (so you will always have a fixed maximum input for this type, this is why I chose to implement text() for Areabox).

  2. Yes indeed I witnessed this problem and it’s kinda hard to fix it consistently for all clients’ installs, but I thought I had fixed it in the last version I’ve sent you. I will take a closer look to fix it and send you a patch.

  3. Thank you for this detailed feedback (with the image you sent me by mail), I will fix this bug and send you a patch.

However, I am currently working on another project and thus won’t be able to code those fixes this week, but I will send you the patches by the middle of the next week (~mid May).


About the overloading functions, yes there are people who are regularly using it but mainly reports their experiences on the french board.

You can find a good example that I didn’t yet post on the wiki:
http://www.dolibarr.fr/forum/511-creation-dun-nouveau-module/28793-release-customfields-module-champs-personnalises?limit=15&start=435#38603

About your bug, I can’t see a problem with your code. Did you try to print the SQL query to check that $object->id returns what you expect, and that the generated SQL query is working? (try with a simple print($sql);die(); ).

PS: you should also use $object->$idvar instead of $object->id, sometimes the field containing the object’s id is not called id in Dolibarr, but CustomFields provides you the field name in $idvar.

The CustomFields FREE edition has just been updated and is now compatible again with Dolibarr v3.3.1. It also includes a backport from PRO to allow compatibility with databases configured with mixed-case columns names.

Available on Dolistore and github.

UPDATE: CustomFields Free and Pro now support recopy on cloning and (only for Pro) recopy on conversion.

Available on dolistore.com, on the github and on the dedicated website customfields.org.

UPDATE: the online demo of CustomFields Pro is now updated to the latest version.

You can now try the latest functionalities like the recopy on conversion.

Could someone enlighten me. Whats recopy on conversion ?

toomanylogins wrote:

This functionality is not yet documented on the wiki but it’s pretty simple conceptually.

Let’s say for example that you have a custom field “cf_id_number” set for commercial offers AND for invoices. Now let’s say that when you close a commercial offer and then convert a commercial offer into an invoice, you want this field “cf_id_number” to be copied over from your commercial offer onto the invoice, because you always want to track down this id number.

If you enable “Recopy on conversion” on the target field (“cf_id_number” in invoices), then the field will be recopied over.

Now this work not only for two modules, but for any chain of modules you may imagine: orders to invoice, commercial offer to order to invoice, etc…

It also works for products lines, thus if you have a custom field for products lines in commercial offers and have the same fields in invoices and enable Recopy on Conversion for the fields in invoices lines, the products’ lines custom fields will also be recopied over.

Recopy on cloning work about the same, but it’s fully automatic and auto-activates for all custom fields when you clone an object.

Hello Stephen,

How do we handle the situation when we have two external tables ( these are from joomla ) and we want to constrain a custom field on each table. The problem is the field name in each table is the same, in our case Field name equals “title”. Obviously we can’t have two fields cf_title. My understanding is that CustomFields uses the field name to look up the constraint therefore we cannot have two fields = cf_title. is that correct ?

This is also an issue for the language file ?

regards
Paul

Hello Paul,

That’s not a problem, you can prepend or append any name you want in addition to the remote field(s) names.

Eg:
cf_prependedname_title
cf_title_appendedname
cf_prependedname1_prependedname2_title_appendedname1_appendedname2

All the field’s names above will correctly fetch the remote “title” field from your constrained table, and there you won’t have any collision with any of your other fields since you can rename your fields in whatever way fits you the best.

CustomFields will automatically guess that “prependedname” and “appendedname” don’t correspond to any remote field, so there won’t be any bug.

Thanks Stephen,

the reason I ask is that I am getting an error when trying to save field with a constraint. The error is as follows.

Error Cannot add or update a child row: a foreign key constraint fails (hausinsure.#sql-c4_35550, CONSTRAINT fk_title FOREIGN KEY (title) REFERENCES j25_n3ttemplate_categories (id))

this is on a test domain and I have another test domain which is working okay (on different server) and I cannot find the cause of the error. It must be in the database as I have run a file comparison.

In the working site table doli_projet_task_customfields

I have these foreign key constraints

CONSTRAINT fk_note FOREIGN KEY (note) REFERENCES j25_n3ttemplate_templates (id),
CONSTRAINT fk_projet_task FOREIGN KEY (fk_projet_task) REFERENCES doli_projet_task (rowid) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT fk_title FOREIGN KEY (title) REFERENCES j25_n3ttemplate_categories (id)

In the site with the error there are no foreign keys on the
doli_projet_task_customfields table.

The asem occurs with doli_projet_customfields this is missing

CONSTRAINT fk_projet FOREIGN KEY (fk_projet) REFERENCES doli_projet (rowid) ON DELETE CASCADE ON UPDATE CASCADE

Any idea what might be causing the problem?

All of the tables are innodb.

Regards
Paul

Deleting and recreating filed removes the error however I still do not get foreign keys created. can you confirm if a foreign key should be created when you add a constraint on a custom field. I’m using the Heidi sql editor to view the tables.
thanks
Paul

Hi, I have a problem with the odt creation. Love your product even in free version, great.
I name my customfiled in products “tarif” (it should through out those customstarifnumbers
and then in the odt table template: row.lines etc I try {line_cf_tarif} and {cf_tarif} but it just says then on the odt invoices {cf_tarif} or {line_cf_tarif} but not the number I put there to the product. I use 3.5.2 german and customfield free V2, in a virtualmachine (testserver, so everything fresh). Can anyone tell me what I can do? Is it a bug? Anyone else has this?
Thanks a lot, have a nice weekend.

Cheers,
Sebastian

@admin: Can please someone delete my both posts in this thread since I am unable to edit them. Found the problem, … :silly: … It is explained in the technical documentation… :whistle: Thanks

Hello,
I have instaled the MODULE PRODUCTS EASY ACCESS and the free custom fields and I wonder if it is a possibility to have the bank account on invoice ODT template. I tried with constraints but doesn’t work({object_bank_account_bank};{company_bank_account_bank})
It’s strange that if I create a custom field for customer invoices like cf_spec and I set constraint llx_user and try to get {cf_spec_user_admin} or {cf_spec_user_name} in ODT it doesn’t work.

Can please someone help me with this issue?
10x
.

I solved it.
for customer bank account on invoice(ODT) use: {cf_customerbank_bank} and {cf_customerbank_number}
where cf_customerbank is vaiable declared in custom fields module with constraint llx_societe_rib (this table has de bank acount info)
PS: put for default value 1.(it will take by default the first bank account declared for that customer)

Hi Sebastian/Striebig,

Would you be able to share your solution with me? My brain seems to be on a go-slow today with the documentation.

Thank you!

Hi,

I’m trying to install Customfields on Dolibarr 3.6 without success.

I download the file htdocs folder from Dolistore, then I zip it (since is not zipped), I upload in the Dolibar folder on the server and unzip.
Then I enter in Dolibarr but the new module is not there.
I made the process 4 times, not working.
Any suggestion?

Thanks

Hello Velectro,

Yes, CustomFields Free and Pro are both compatible with Dolibarr 3.6 without any change to the code.

But it’s very weird that you got a non-zipped htdocs folder from Dolistore. Please retry to download or download from the github, this would be safer.