1

I have a form with inputs that are rendered dynamically through custom metadata relationship fields that relate to Opportunity Line Item fields. These inputs work and bind properly except for date fields.

When a value is changed we call an apex method to save records through actionSupports. All the values save except for date values.

Visualforce snippet:

<tr>
    <td></td>
    <td colspan="9">
        <apex:repeat value="{!s.inputFields}" var="field">
            <div class="italicizedheader">
                {!field.Label}: 
                <span style="font-style:normal">
                    <apex:inputField value="{!s.lineItem[field.Destination_Field__r.QualifiedAPIName]}">
                        <apex:actionSupport event="onchange" rerender="lineItemOutputPanel,pageMessageId" action="{!RecalculateNoEffect}">
                            <apex:param value="{!s.lineItem.Id}" assignTo="{!lineid}" name="lineid"/>
                        </apex:actionSupport>
                    </apex:inputField>
                </span>
            </div>
        </apex:repeat>
    </td>
    <td></td>
    <td></td>
</tr>

Apex Method:

public PageReference RecalculateNoEffect()
{
    List<OpportunityLineItem> olis = new List<OpportunityLineItem>();
    for (ShoppingCartItem q : shoppingCart) {
        olis.add(q.lineItem);
        System.debug('Start Date: ' + q.lineItem.Maint_Start_Date__c);
    }

    update olis;

    //Refresh shopping cart
    shoppingCart = RefreshShoppingCart();

    return null;
}

10:12:05.0 (286799223)|USER_DEBUG|[1713]|DEBUG|Start Date: null

The dynamic displaying isn't a problem because I have hardcoded the api field name to an apex:inputField and it also does not save.

The date picker shows when the input has focus and displays the selected date, but when the actionSupport method is called the value is null.

enter image description here

Why are the date values not binding?

  • The problem was elsewhere in my visualforce. I was dynamically hiding a different input with the same field value with css. Visualforce didn't know how to handle 2 of the same fields with different values – TemporaryFix Jun 10 at 20:23

Your Answer

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

Browse other questions tagged or ask your own question.