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

How can I set a Field default based on cross object fields? ie Opp's & Accounts



I would like to create a Field on Opportunities that specified the Discount applied (%). I need it to have a default which is determined by knowing the Sales Office that Owners the Account. This information is already stored at the Account level and creating and editable Field at the Opportunity level to store the same info creates duplication and potential for error. The Discount Field must be editable be the User level so it can't be a Formula Field.


The Default Value equation editor would not let me access cross-object information or the read-only field I created on the Opportunity Object, which I created in desperation, to display the Account Sales Office Field.


Is what I am trying to achieve possible?

If so, is it only possible with Apex Triggers?




What you are trying to achieve  is that the default value of an object has a value from a related object.

This is not possible via trigger too , as in trigger the value will be assigned only after the record is saved, and after reading your requirement it seems you want to set the value of the field to a certain value in a related object when the object is being created, but the user should be able to edit it too.

This type of functionality can be achieve via custom visual force pages.


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.