0

I want to do something pretty basic: Enter a Sales Order Number (Lookup field) and then select the Serial Number of an Item from a Picklist.

The following code is working but it's not reRendering the S/N field once a sales order number is changed. The only way the picklist is getting updated is by saving the record with the Sales Order Number.

I read about people having difficulties with Event="OnChange" with lookup fields not triggering the action support.

Should I design this differently?

VF page:

    <apex:page standardController="Customer_Feedback__c" extensions="CustomerFeedbackControllerExtension" lightningStylesheets="true" name="SalesOrderSection" >
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection title="SO Visualforce test" columns="2">
            <apex:OutputField value="{! Customer_Feedback__c.GAT_Sales_Order__c}" id="SalesOrder">
                <apex:actionSupport event="OnBlur" reRender="selectListValues" action="{!SoPopulated}" focus="selectListValues" />
            </apex:outputField>

            <apex:selectList value="{! Customer_Feedback__c.S_N__c}" title="S/N" multiselect="false" size="1" id="selectListValues">
                <apex:selectOptions value="{!SNOptions}"/>
            </apex:selectList>

            </apex:pageBlockSection>
            <apex:inlineEditSupport event="OnClick"/>
           <apex:pageBlockButtons location="top">
            <apex:commandButton value="Save" action="{!save}" id="saveButton"/>
            <apex:commandButton value="Cancel" action="{!cancel}" id="cancelButton"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>   
    </apex:form>   
</apex:page>

Controller Extension:

public class CustomerFeedbackControllerExtension {

    public List<SO_Item__c> SOItems {get; set;}
    public Customer_Feedback__c cf {get; set;}
    public Id SOId;

    public CustomerFeedbackControllerExtension (ApexPages.StandardController stdcontroller) {
        cf = (Customer_Feedback__c)stdcontroller.getRecord();

    }


    public void SoPopulated()   
    {     
        SOId = cf.GAT_Sales_Order__c;
        system.debug('About to triger S/N Options');
        getSNOptions();

    }

    public List<selectOption> getSNOptions()
    {   SoId = cf.GAT_Sales_Order__c;
        system.debug('About to query SO Items. This is SOId:'+SOId);
        SOItems = [SELECT id, Part_Number__c, S_N__c FROM SO_Item__c WHERE SOId__c=:SOId];      
        List<SelectOption> Options = new List<SelectOption>();
        Options.add(new SelectOption('','-None-'));
        for(SO_Item__c Items : SOItems)
        {
            Options.add(new SelectOption(Items.S_N__c,Items.S_N__c));
        }
        system.debug('Return Options is next');
        return Options;
}

}
  • if you temporarily remove the inlineeditSupport (and change the outputField to an inputField) does it work as you desire? – cropredy Apr 25 at 0:41
  • @cropredy I tried that and it doesn't work. – Alejandro Flores Apr 25 at 17:50

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.