Hey,
I want to connect the Contacts with the event Attendies . For this I added a additional Dropbox to the „ Add Attendies“ list. And add the Contact class to it.
Now I want that the name and firstname field gets automatically filled. Is this possible with a JS onchange function?
BR and thanks!
Do you mean that you created a Complementary Attribute under the project/event module in configuration?
if so you might not need a javascript function.
I think that perhaps you can use the ‘Computed field’
You can enter here a formula using other properties of object or any PHP coding to get a dynamic computed value. You can use any PHP compatible formulas including the "?" condition operator, and following global object: $db, $conf, $langs, $mysoc, $user, $objectoffield.
WARNING: If you need properties of an object not loaded, just fetch yourself the object into your formula like in the second example.
Using a computed field means you can't enter yourself any value from interface. Also, if there is a syntax error, the formula may return nothing.
Example of formula:
$objectoffield->id < 10 ? round($objectoffield->id / 2, 2): ($objectoffield->id + 2 * $user->id) * (int) substr($mysoc->zip, 1, 2)
Example to reload object
((($reloadedobj = new Societe($db)) && $reloadedobj->fetchNoCompute($objectoffield->id) > 0) ? $reloadedobj->array_options['options_extrafieldkey'] * $reloadedobj->capital / 5: '-1')
Other example of formula to force load of object and its parent object:
(($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($objectoffield->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref: 'Parent project not found'
Yes that’s true.
Okay but how to use it and where?
I never read about it.
BR
you simply create 1 or more additional Complementary Attributes which I think has to be of type string, and then you fill in the correct php code in the computed field to select data from the other field
This new extra complementary attribute should then be filled with the name