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
Tony DeMarcoTony DeMarco 

Allowing users to Edit "Field Set" fields on a Custom VF Page

I am employing Field Sets on a custom Opportunity Page due to a need to reduce the use of Formula fields, and instead leverage the lookup capabilities of a VF page.  As a bonus, I am looking to make all fields of the Field Set editable, even those of the type Account > fieldName.

User-added image
My question is if it is possible to edit the related fields on the Account from my Opportunity.  For instance, I would like to be able to edit Account ID > Alliance, but when I do, the value does not save.  However, I am able to save Opportunity fields that are not look ups in the field set.

Is this something that will require Apex in order to achieve.  I'm thinking that is probably so, but I'm not clear.

Here is the page block section I have for Accounts on the Opportunity:
 
<apex:pageBlockSection title="Client Information on Account"/>
	<apex:pageBlockSection columns="2">                    
	<apex:repeat value="{!$ObjectType.Opportunity.FieldSets.Related_Account_Information}" var="f">
	<apex:inputField value="{!Opportunity[f]}">
	</apex:inputField> 
	</apex:repeat>
 </apex:pageBlockSection>

Thanks in advance,

TDM
Shashikant SharmaShashikant Sharma
In apex you could not update related records field. May be what you could do is to create another instance of account and put field values from

account.FieldAPIName = opp.account.FieldAPIName;

You could retrive fields from field set in apex and iterate over it.

Let me know if you need more input.

Thanks
Tony DeMarcoTony DeMarco
Thanks, Shashikant.

OK, I figured that.  So is it best practice not to use a VF Standard Controller and instead use a Custom Controller and then use Apex code to iterate over the field sets? 

Any advice, or perhaps a link to a good source would be appreciated.
Tony DeMarcoTony DeMarco
Addendum to last question:  How is best to approach Standard Controller with Extension or Custom Controller?

TDM