Hello,
Sugar OS V4.5.0f
I the opportunities I created 2 fields as decimals. I made a third one which is supposed to display the sum of the 2 first fields. How do I do that?
Many thanks,
Alan
Hello,
Sugar OS V4.5.0f
I the opportunities I created 2 fields as decimals. I made a third one which is supposed to display the sum of the 2 first fields. How do I do that?
Many thanks,
Alan
Edit the php file (located in the applicable modules directory) which corresponds to the view[file] in which will display such..
Add a lil arithmatic (sp?) php, to uh.... hmmm... add those two variables (fields as you might call or think of them) of which are assigned to some new and unique variable name. This new & unique variable name which holds your desired sum, will be displayed in your view html file using that same variable name...
Oh, heck, I'm falling asleep and it's too late for this...
Your mods will be a few lines of code in the php file and a simple addition of that field to your view html file..
I.E. modules/Opportunities/DetailView.php and DetailView.html
If you have absolutely no clue what or how, spend the day dissecting those two files, along with constant referencing and reading @ php.net...
php.net has plenty of sample code for such arithmatic operations, and would be nothing more than cut & paste essentially..
A non programmer could accomplish your desired goal within a couple hours, while learn qlot of useful and neccessary knowledge about sugar throughout the process..
hmm... merci Chrisky!
I guess I'm gonna have to learn some php...
Alan
I know how to play with DetailView.html file (since it's only html) but I'm quite lost when it gets to the DetailView.php. I looked in the different php files in the modules and the fields are used in many different php files so I don't get what the interaction between these files are... Is the entry only to be made in DetailView.php? Could you help me out with the code I have to write in it? That would be awsome!![]()
Thanks,
Alan
It's not that easy. The variables you created are custom fields and they're nowhere near DetailView.php.
Hmm...Originally Posted by lvangool
First off you're wrong my friend..
It's fair to assume that Alan created two custom fields in the oppotunities module by the sounds of it:
"I[n] the opportunities I created 2 fields as decimals."
That said, these field names (variables) are already defined and available inside DetailView.php
Something along the lines of this is what you want to add to the php file:
$calculatedsum = (($focus->my_custom_decimalfieldname1_c) + ($focus->my_custom_decimalfieldname1_c));
$xtpl->assign("MY_SUM_FIELD", $calculatedsum);
And then you would just add the following, into your html view file wherever you wanted that data to be displayed:
{MY_SUM_FIELD}
I'm sure my syntax is wrong, while I can testify to the mind halting effect of sleep depreviation...
Anyways, it's not hard to accomplish, only a few lines of code if that...
I created Indeed a number of fields an integrated them in the edit and detail view. But there is no reference to these fields in Detailview.php or edtiview.php. In these 2 view.php I inserted the following lines from your reply (with my fields):
$calculatedsum = (($focus->jan2006_c) + ($focus->feb2006_c));
$xtpl->assign("IST_TOTALTURNOVER_C", $calculatedsum);
under the following lines found in both view.php:
//Add Custom Fields
require_once('modules/DynamicFields/templates/Files/EditView.php');
AND IT WORKS!!!!! Thanks a lot!!!![]()
![]()
Alan
You're very welcome and I'm glad you achieved your goal!
Though that (the code I wrote and posted for you) was like too easy and only seconds for me, I honestly did not expect it to be used or applied..
I want to take the time (this post) to complement you and let ya know that I greatly respect you.
You may not have yet ventured into programming (at least in PHP) but if you ever do, you'd be a great programmer...
Anyways Alan, most people would not have been been able to achieve your goal, even with detailed step by step instructions. You were able to achieve it with just being given the little bit of neccessary code while figuring out on your own everything else and subsequently doing it.
You're very very smart, and if you don't know something (at least technical related) you are able to learn it if you so chose, of which skill and ability makes you smart and something to be proud of.
Keep in touch and let me know if you have any other questions I might be able to help with
Thanks Chrisky, that's too much!![]()
It wasn't so difficult since you gave me the whole code...
But since you're offering your helpI posted some other threads that didn't get any answer:
http://www.sugarcrm.com/forums/showthread.php?t=17851
http://www.sugarcrm.com/forums/showthread.php?t=17852
My next funny task will be to export and import all the data from 3.5 to 4.5...![]()
Thanks for everything and take care,
Alan
Hi,
Back again with a surprise (for me; I guess u know that)
The sum displayed is not being saved in the DB! Cause when I want to add the result with another variable it displays just the amount of the variable, not the sum I got previously.
Another issue is that I want to used in my calculations a variable that I "feed" through a dropdown with either 8; 6,5 or 0. But When I add this field to another one, the result only shows the other one (doesn't consider what's in the field with the dropdown).
Thanks for the help!
Alan
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks