Hi there
How can i get something like this in calculated fields?
concat(
(if team = products then 'prod'
else if team = sales then 'sale'),(left(opportunity.id,3),year(now),motnh(no w))
thanks
Paul
Hi there
How can i get something like this in calculated fields?
concat(
(if team = products then 'prod'
else if team = sales then 'sale'),(left(opportunity.id,3),year(now),motnh(no w))
thanks
Paul
You can use customCode into yout field on your edit/detail view to renderize it, or in your field vardefs, you can assign a function reponsible to diplay the field contents. This second case is very more flexible.
Rafael Queiroz Gonçalves
Advanced OMG UML Certified Professional
Sun Certified Enterprise Architect for the Java Platform
Sun Certified Programmer for the Java 2 Platform
IBM Certified Advanced Application Developer - Lotus Notes and Domino
IBM Certified Application Developer - IBM WebSphere Portlet Factory
Computer Science Mastering / UFSC - PPGCC
What to do depends:
- What edition are you using? CE? Pro?
- Do you want to show the calulated value only or do you want to store it in database?
Stefan Ulrich Sauer
System Analyst
Devoteam Danet GmbH
Gutenbergstraße 10
D-64331 Weiterstadt
Germany
email: Stefan-Ulrich.Sauer@devoteam.com
http://www.devoteam.de
I am using pro - Should store to the database.
In Pro you can use the Formula Builder with 6.1 for calculated fields.
Some documentation can be found here:
http://www.sugarcrm.com/crm/support/...n.html#1670624 (search for "Calculated Value Fields")
http://www.sugarcrm.com/crm/support/...c.html#9000011
I've tried to create a variable using your formula (in my 6.2 installation). Some parts are working fine, other methods are not avilable in the formula builder. For 'if A then B else C' you can use the method 'ifElse(A,B,C)', for 'A=B' this would be 'equal(A,B)'. There is a method monthofyear(<date>) that you could call 'monthofyear(now())'. For 'left' and getting year there seems to be no method available in the Formula Builder until now.
Stefan Ulrich Sauer
System Analyst
Devoteam Danet GmbH
Gutenbergstraße 10
D-64331 Weiterstadt
Germany
email: Stefan-Ulrich.Sauer@devoteam.com
http://www.devoteam.de
What could you do instead?
With 'before_save' logic hook you could do such a calculation and assign the result to the field.
Here a simple example for the implementation:
PHP Code:<?php
class MyOpportunitiesLogicHooks{
function calculateProvisionEuro(& $bean, $event, $arguments) {
$bean->provision_euro_c = $bean->amount * $bean->provision_prozent_c / 100.0;
}
}
?>
Stefan Ulrich Sauer
System Analyst
Devoteam Danet GmbH
Gutenbergstraße 10
D-64331 Weiterstadt
Germany
email: Stefan-Ulrich.Sauer@devoteam.com
http://www.devoteam.de
Found out how to add new methods to formula builder:
1) Create new method implementation in directory custom\include\Expressions\Expression\<data type>. Copy an existing file from include\Expressions\Expression\<data type> and edit ... It is more or less self-explanatory. Please be aware that the php file contains a JavaScript implementation of the method too.
2) Remove files in cache/Expressions
3) Start Studio (this will force Sugar to re-create the files in cache/Expressions)
Now the new method should be available for use in Formula Builder.
Stefan Ulrich Sauer
System Analyst
Devoteam Danet GmbH
Gutenbergstraße 10
D-64331 Weiterstadt
Germany
email: Stefan-Ulrich.Sauer@devoteam.com
http://www.devoteam.de
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks