Reply
Visitor
MichaelBrill
Posts: 2

Referring to fields on related objects

Sorry if this has been covered a million times... but I'm trying to figure out if it's possible to have a custom formula that refers to a specific field on a related object - either with simple reference to a master object or aggregate function across a detail object. For instance, if I have a number of Orders associated with an Account, I'd like the sum of the Amount field in Orders to be visible at an Account level. What is the best way to accomplish this?
Moderator
DevAngel
Posts: 3,194

Re: Referring to fields on related objects

No, as of this release that is not possible. You may only reference data on the object in which the formula is defined.
Dave
Developer Evangelism
BLOG - blog.sforce.com

Follow me on twitter @dcarroll
Visitor
MichaelBrill
Posts: 2

Re: Referring to fields on related objects

What is the best approach for invoking external application logic after saving an instance of a salesforce object. For instance, let's say I have a custom field on Accounts called AvgOpptySize. Every time I save the Account or save an Opportunity for the Account, I want to execute some Javascript/AJAX code that calculates the average opportunity size and then assigns that to AvgOpptySize in the Account object. Where does this code live and is there a way to automatically invoke it upon a Save on Account or Opportunity?
Moderator
DevAngel
Posts: 3,194

Re: Referring to fields on related objects

[ Edited ]

At this point in the evolution of salesforce.com, the typical solution for this kind of problem is to write an scontrol that takes the Account Id and queries for opptys on that account and calcs the avg then writes it back to the field on the account and then refreshes the account screen.

The scontrol is invoked by the user clicking the "Update Avg Oppty Size" web link or formula field on the account detail screen. There just isn't any mechanism by which you can inject your custom logic in to the save operation.

Now, Daroz has been preaching heresy (def: A person who holds controversial opinions, especially one who publicly dissents from the officially accepted dogma of the Roman Catholic Church Salesforce.com.) about injecting script into various objects. See http://forums.sforce.com/sforce/board/message?board.id=scontrols&message.id=890.  Please pay attention to all the stuff in RED.

This kind of pre/post save logic is something that we are researching for a future release.

Message Edited by DevAngel on 01-24-2006 01:50 PM

Dave
Developer Evangelism
BLOG - blog.sforce.com

Follow me on twitter @dcarroll
Trusted Contributor
daroz
Posts: 265

Re: Referring to fields on related objects



DevAngel wrote:

Now, Daroz has been preaching heresy (def: A person who holds controversial opinions, especially one who publicly dissents from the officially accepted dogma of the Roman Catholic Church Salesforce.com.) about injecting script into various objects. See http://forums.sforce.com/sforce/board/message?board.id=scontrols&message.id=890. Please pay attention to all the stuff in RED.






It's feels good to be loved. ;) Thanks Dave.
-- Daroz, The Heretic

SFDC Heretic Blog