Hi,
Maybe you could try creating a logic hook. That's what I did the other day, and it worked! I had the same issue - I needed to set the value of a field by concatenating the values of two other fields. So here's what I did:
1. Created the file custom/modules/ModuleName/SetField.php, containing the code:
PHP Code:
<?php
require_once('data/SugarBean.php');
require_once('include/utils.php');
class SetField {
function setField(&$bean, $event, $arguments) {
$new_value = $bean->field1 . ' ' . $bean->field2;
$bean->field3 = $new_value;
}
}
?>
2. Created the file custom/modules/ModuleName/logic_hooks.php, containing the code:
PHP Code:
<?php
$hook_version = 1;
$hook_array = Array();
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(1, 'setField', 'custom/modules/ModuleName/SetField.php','SetField', 'setField');
?>
This solution doesn't set 'field3' while you're typing field1 and field2; it waits until you click Save. It's a 'before_save' logic hook. The Sugar Developer Guide describes all the other types of logic hooks available.
I hope this all helps.
AG
Bookmarks