Is it possible to create a custom formula field in sugarcrm? In the bugs module, we would like to add 5 custom editable numeric fields. In view mode, show a calculated score based on those 5 values.
Is it possible to create a custom formula field in sugarcrm? In the bugs module, we would like to add 5 custom editable numeric fields. In view mode, show a calculated score based on those 5 values.
It is possible, but needs some coding (in CE). In payed editions you can use "SugarLogic" for this (define a calculated field via configuration in admin->studio).
Last edited by sts; 2013-01-16 at 01:43 PM.
Stefan Ulrich Sauer
System Analyst
Devoteam GmbH
Gutenbergstraße 10
D-64331 Weiterstadt
Germany
email: Stefan-Ulrich.Sauer@devoteam.com
http://www.devoteam.com
http://www.devoteam.de
- Devoteam GmbH is SugarCRM Partner -
Can you direct me to some information or samples on programming that? We have basic experience with PHP so we can figure it out, but it will be slow.
Basically what I want to do is using the Bugs module, add 6 custom fields that store integer values. 5 will be editable by users, the 6th will be calculated from the other 5 values. Total calculated value will be a formula from the other 5, not just a sum total.
First you create these fields via admin->Studio and place 5 unto Edit View and the sixth (or all) unto Detail View.
Programming:
You'll have to add a logic hook in your Bugs' module (before_save) and here you do the calculation (set the value of the sixth field using the values of the other 5).
I've found a nice coding example here which does some calculation in a logic hook:
custom/modules/<modulename>/process.php:
PHP Code:<?php
// prevents directly accessing this file from a web browser
if(! defined('sugarEntry') || ! sugarEntry)
die('Not A Valid Entry Point');
class Process
{
function process(&$bean, $event)
{
// calculate item profit
$bean->t_profit_c = ($bean->t_sale_price_c - $bean->t_item_cost_c);
// calculate sale profit
if(!empty($bean->t_qty_sold_c))
{
$bean->t_sale_profit_c = ($bean->t_qty_sold_c * $bean->t_profit_c);
}
}
}
?>
custom/modules/<modulename>/logic_hooks.php:
I hope this helps.PHP Code:<?php
// Do not store anything in this file that is not part of the array or the hook version. This file will
// be automatically rebuilt in the future. $hook_version = 1;
$hook_array = Array();
// position, file, function
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(1, 'process', 'custom/modules/<modulename>/process.php', 'Process', 'Process');
?>
Stefan Ulrich Sauer
System Analyst
Devoteam GmbH
Gutenbergstraße 10
D-64331 Weiterstadt
Germany
email: Stefan-Ulrich.Sauer@devoteam.com
http://www.devoteam.com
http://www.devoteam.de
- Devoteam GmbH is SugarCRM Partner -
Thank you. Works perfect.
Thanks Sir I too Have That Poblem i was gonna post new topic but since i saw this one there is no need now![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks