I have a visualforce page that is currently iterating through the fieldsets within the OpportunityLineItems object. Everything is displaying correctly with the input fields where the user needs to type in the data. What I need it to do is when the person clicks the save button, I need to store those input values in my controller, so that I can later write them to the Product2 object for the particular OpportunityLineItem. I know how to do it with a single field and stuff like that, but I'm having trouble in terms of how I am supposed to do it with a dynamic fieldset.

Any help would be greatly appreciated. If there is any details that may be important that I left off, let me know. Thanks!


public without sharing class OliWizardExt 
    OpportunityLineItem oli;
    Opportunity opp;
    List<oliWrapper> digitalProducts;
    List<oliWrapper> oliToScheduleList = new List<oliWrapper>();    
    Id thisOpportunityId;
    List<pbeWrapper> selectedProducts;  
    List<OpportunityLineItem> saveOliList;
    public Set<String> prodSet {get; set; }
    public Map<String, List<Schema.FieldSetMember>> activeFieldsets {get; set;}
    public List<String> currentProdNameList {get; set;}
    public String currentProductName {get;set;}
    public List<Schema.FieldSetMember> fsm {get;set;}

    public OliWizardExt(ApexPages.StandardController con)
    private void onLoad()
        System.debug('OpportunityLineItem: ' + oli2);
        //load opportunity
        List<Opportunity> oppList = new List<Opportunity>();
        thisOpportunityId = ApexPages.currentPage().getParameters().get('oppId');
            opp=[Select o.Pricebook2Id, o.Name, o.Id From Opportunity o where o.Id=:thisOpportunityId limit 1];
            opp = new Opportunity();
            opp.addError('Opportunity Id must be specified');
        availableProducts = new List<pbeWrapper>();

    public void buildQuery()
            opp.addError('Pricebook must be specified');


    public List<pbeWrapper> getSelectedProducts()
        return selectedProducts;

VisualForce Page

    <apex:sectionHeader title="Opportunity Wizard" subtitle="Product Schedule Selection"/>
    <apex:form >
        <apex:messages />
        <apex:PageBlock title="Confirmation" id="submitProducts">
        <apex:pageBlockButtons >
            <apex:commandButton action="{!saveShareOppSched}" value="Save"/>
            <apex:commandButton action="{!cancel}" value="Cancel" onclick="return confirmCancel()" immediate="true"/>


            <apex:repeat value="{!prodSet}" var="f">
            <apex:pageBlockSection title="{!f}" columns="1"> <!--title="Digital Display Product" -->
                <apex:repeat value="{!selectedProducts}" var="prods">
                    <apex:pageBlockTable value="{!prods.pbe.Product2.Name}" var="indProd" rendered="{!IF(prods.pbe.Product2.IO_Family_Field_Set__c == f, true, false)}">
                    <!--<apex:repeat value="{!testProds[f]}" var="prods">
                    <apex:pageBlockTable value="{!prods}" var="indProd">-->

                        <apex:repeat value="{!$ObjectType.OpportunityLineItem.FieldSets.Opportunity_Product}" var="oppProd">
                            <apex:column headerValue="{!oppProd.Label}">
                                <apex:outputText value="{!indProd}"></apex:outputText>
                        <apex:repeat value="{!activeFieldsets[f]}" var="fieldValue"> 
                            <apex:column headerValue="{!fieldValue.label}">
                                ********<apex:inputField value="{!OpportunityLineItem[fieldValue.fieldpath]}"></apex:inputField>*******



  • 1
    Can you please trim out some of the irrelevant code to make this easier for us to go through?
    – Adrian Larson
    Dec 14, 2015 at 18:09
  • Yeah, sorry. I just didn't know what may be useful.
    – Stephen
    Dec 14, 2015 at 18:18
  • Well the weeding out process will help you figure that out and maybe help you answer your own question. If you are not willing to put in the work to figure out what's relevant, how can you ask us to do the same? Try to be courteous of our time. :)
    – Adrian Larson
    Dec 14, 2015 at 18:19
  • I know, I completely understand.
    – Stephen
    Dec 14, 2015 at 18:22
  • 1
    might be helpful to post a screen shot of your page - you have a lot of repeats and tables in the VF markup
    – cropredy
    Dec 14, 2015 at 20:16

1 Answer 1


Try binding the input text to a List On the controller and use that to persist to the DB.

(NOTE: I can't see your wrapper definitions, and I am having trouble following all the code, so you may want to pick the correct variable. I am just trying to give you a quick sample)

<apex:repeat value="{!oliList}" var="oneOli">
  <apex:column headerValue="{!fieldValue.label}">
    <apex:inputField value="{!oneOli[fieldValue.fieldpath]}"></apex:inputField>

And, on the controller definition

List<OpportunityLineItem> oliList {get;set}

Make sure to populate it properly and, on the save method, you can do

upsert oliList; //or any operation you want
  • 1
    Thank you!!!!! It took me a few changes, but the idea was definitely helpful and led me to the right answer!
    – Stephen
    Jan 7, 2016 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.