function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kchurchkchurch 

How to create a calculated field using fields from different objects?

We want to be able to have a calculated field in a custom object A, which is the result of adding field values together from custom object B and custom object C. So for example:

 

Custom_Object_A.field = Custom_Object_B.field + Custom_Object_C.field

 

I understand that the latest version of salesforce supports formulae fields that allow me to automatically calculate a value in one field based on the values in other fields, however as far as I’m aware this only works with fields associated the same object. We want to do something similar apart from the fields we want to use in our calculation are spread across different objects.

 

I’m sure there is a way to do this using sforce controls but I can’t find that many samples online. I was wondering if anyone has any sample code or suggestions about how I might go about implementing this functionality?

 

Also, we don’t want to have to click on a link to execute the sforce control. Instead, what we’d really like is to have the calculated field in our custom object A update/change automatically whenever the values in custom object B or C change. So we’d like to somehow attach or associate the sforce control with a field. Is there any way of doing this? Any help would be greatly appreciated.

 

Thanks

Karen

kchurchkchurch

Apologies for my earlier post - it looks like this topic has been covered previously in these forums and from what I can see, it's possible to write an sforce control to carry out the calculation across multiple objects but you have to manually invoke the scontrol by clicking on a link or something similar. See this previous post for further details: http://forums.sforce.com/sforce/board/message?board.id=scontrols&message.id=966

 

However, on the off chance that someone has found a way around this - I'd love to hear it :-) And if anyone knows where I can find some sample sforce controls, I'd really appreciate it.

 

Thanks,

Karen

Ron HessRon Hess
there are several examples of scontrols on the AppExchange, look in the "Components" area, then run some of the test-drives , then you can go in an browse the "Custom S-Controls" area of the test drive to see the actual source code. 
    Most of these use the AJAX Beta3.3 toolkit.