You need to sign in to do that
Don't have an account?
Lee Yakiwchuk
Dynamic FieldSet not saving records/fields correctly
Hi,
We have a modified Edit All for our Opportunity Products. There is a column on the Edit All page that contains a number of dropdown fields that are the configuration for the Product on that line. We dynamically assign the Field Set to the product and display the config fields for it. This all displays fine and the dropdowns work for the user. However, when we save it will use the last fieldset as a template for saving.
For example:
Product 1 has Config A, B & C
Product 2 has Config B & C
When saved Product 2 saves fine.
Product 1 saves Config A into B and Config B in C and discards Config C altogether.
This makes sense as the last field set the page knows about is Product 2's. Has anyone run into this and gotten it to remember Product 1's FieldSet so it binds the values to the correct field?
Here is the code we are using to display the code in a single column of the Edit All table:
<apex:repeat value="{!$ObjectType.OpportunityLineItem.FieldSets[layout]}" var="f" >
<div style="margin-bottom:1em">
<span id="myLabel" class="label" style="align:left"> {!f.fieldPath} </span>
<apex:inputField value="{!oppLItem[f]}" required="{!OR(f.required, f.dbrequired)}" onchange="foo(this);"/><br/>
</div>
</apex:repeat>
Thanks!
Lee
We have a modified Edit All for our Opportunity Products. There is a column on the Edit All page that contains a number of dropdown fields that are the configuration for the Product on that line. We dynamically assign the Field Set to the product and display the config fields for it. This all displays fine and the dropdowns work for the user. However, when we save it will use the last fieldset as a template for saving.
For example:
Product 1 has Config A, B & C
Product 2 has Config B & C
When saved Product 2 saves fine.
Product 1 saves Config A into B and Config B in C and discards Config C altogether.
This makes sense as the last field set the page knows about is Product 2's. Has anyone run into this and gotten it to remember Product 1's FieldSet so it binds the values to the correct field?
Here is the code we are using to display the code in a single column of the Edit All table:
<apex:repeat value="{!$ObjectType.OpportunityLineItem.FieldSets[layout]}" var="f" >
<div style="margin-bottom:1em">
<span id="myLabel" class="label" style="align:left"> {!f.fieldPath} </span>
<apex:inputField value="{!oppLItem[f]}" required="{!OR(f.required, f.dbrequired)}" onchange="foo(this);"/><br/>
</div>
</apex:repeat>
Thanks!
Lee
<apex:variable does not work as you could expect when it is under an <apex:repeat
Try this
All Answers
I suggest you to ensure that fields are being correctly shown, create data with workbench (or other) with differents values for every field and test.
I made an apex component that do the magic, here is some of the component's code
We have the correct fields as they display the inital values without issue. However when we save them they all get reassigned to the wrong fields. All of the saved fields get saved to the mapped fields for the fieldset Product 2 uses instead of the fieldset for Product 1.
Thanks,
Lee
Could you post the complete loop over line items?
Here is the code, I removed the columns to make it a bit shorter.
Thanks,
Lee
<apex:variable does not work as you could expect when it is under an <apex:repeat
Try this