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
Joseph BaroneJoseph Barone 

Reset VisualForce Picklist Lookup fields for each new record

Hello,

I have a VF page that allows for multiple entries to be created on the same page.  Two of the fields I'm referencing are Parent- Child lookup fields that I've created as a picklist (one is Client and other is Matter).  Matter is dependent on Client.  

The picklists works great and provide the right details.  The issue I run into is when I go to add in a new record, the Picklists retain their values from the previous entry.  If I try to change the entries, it gives me validation error.  As soon as I change the values back to the previous line it works great.   I have a feeling it is tied to how I have the VF page created, but I'm not 100 % sure.  Any suggestions would be appreciated.

Thank you,
 
<apex:page Controller="AddmultipleTimes" sidebar="false" action="{!setInitials}">
    
    <apex:form >
         
    <apex:pageBlock mode="edit" id="title">
    <table width="100%" border="0">
         <tr>
         <td width="100" valign="top">
         
     <apex:pageBlock title="Change Timekeeper" mode="edit" id="initialchange">
        
          <table cellpadded="2" cellspacing="2">
          <tr>
         <apex:inputtext value="{!initials2}" />
         <apex:commandButton action="{!newTimeKeeper}" value=" Submit Initials " style="color:red" reRender="thetable, mainpage">
                    
            </apex:commandButton>
          </tr>
          </table>         
        
        </apex:pageBlock>
             </td>
        <td valign="top">
        <apex:pageblock id="mainpage" title="New Time Entries for {!initials}" >
        
             <apex:pageMessages />
         
              
            <apex:pageblocktable value="{!listNewtime}" var="lnt" id="thetable"> <apex:variable value="{!0}" var="cnt"/>
              
            
                
                <apex:column width="100px">
                <apex:commandButton action="{!removeLine}" value=" X " style="color:red" reRender="thetable">
            <apex:param name="TimeCount" assignTo="{!TimeCount}" value="{!cnt}"/>
            
            </apex:commandButton>
          </apex:column>
                <apex:column >
                <apex:commandButton action="{!copyValues}" value="Copy" reRender="thetable">
                <apex:param name="TimeCount2" assignTo="{!TimeCount2}" value="{!cnt}"/>
                </apex:commandButton>
                </apex:column>
           
                <apex:column headerValue="Entry">   
                <apex:outputText value="{!cnt}" />
               <apex:variable var="cnt" value="{!cnt+1}"/>       
                                       
                </apex:column>
       
        <apex:column headerValue="Date">
            <apex:inputField value="{!lnt.Date__c}"/>
        </apex:column>
        
        <apex:column headerValue="Client Code">
        <apex:inputField value="{!lnt.Client_Code__c}" />
        </apex:column>
        <apex:column width="100px" headerValue="Matter #">
        <apex:inputField value="{!lnt.Matter__c}" />
        </apex:column>
                
        <apex:column headerValue="Client Code -- Test">
   		<apex:selectList size="1" value="{!clientc}">
            <apex:selectoptions value="{!clientobj}"/>
            <apex:actionSupport event="onchange" reRender="MatterList"/>
            </apex:selectList>
          
        </apex:column>
        <apex:column width="100px" headerValue="Matter # -- Test">
        <apex:selectList size="1" value="{!matt}" id="MatterList">
            <apex:selectoptions value="{!mattobj}"/>
            <apex:actionSupport event="onchange" />
            </apex:selectList>
                       
         </apex:column>
         
        <apex:column width="100px" headerValue="Hours">
        <apex:inputField value="{!lnt.Hours_Worked__c}"  style="width: 100px"/>
        </apex:column>
        <apex:column width="100px" headerValue="Task">
        <apex:inputField value="{!lnt.Tasks__c}" style="width: 100px"/>
        </apex:column>          
        <apex:column width="1000px" headerValue="Narrative">
            <apex:inputField value="{!lnt.Narrative__c}" style="width: 1000px"/>
        </apex:column>
  
        
            </apex:pageblocktable>
      
            
        <apex:pageBlockButtons >
            <apex:commandbutton value="Add New Row" action="{!addTime}" rerender="thetable"/>
            <apex:commandButton value="Save Times" action="{!saveTime}"/>
            
            </apex:pageBlockButtons>
            </apex:pageblock>
             </td>
        </tr>
        </table>
        </apex:pageBlock>
    </apex:form>
</apex:page>