• Raviteja Epuri 1
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi Experts!!

Clone functionality is not working as expected :(

Expected requirement is after click of clone i want new row to be added at the last and Sequesnce number is in order.
pageblock table on page load

Issue is once we click on clone its changing the sequence number(along with other data in the row) of source row.
 
Page block table on click of clone

Code :
<!-- Action funtion to clone entry -->
        <apex:actionFunction action="{!cloneEntry}" name="cloneEntry1" reRender="pgMsgs,lstproducts" status="pageStatus">
            <apex:param name="entryToClone" value=""/>
        </apex:actionFunction>
<apex:pageBlockTable value="{!lstEntries}"  var="oli" width="80%" id="pbTable" rendered="{!lstEntries.size >0}">          
                <apex:column >
                  <u><a style="cursor: pointer;" onclick="cloneEntry1('{!oli.APT_Sequence_Number__c}');"> <b>Clone</b> </a></u>                 
                </apex:column>
                <apex:column headerValue="Sequence Number">   
                 <b><apex:outputField value="{!oli.APT_Sequence_Number__c}" />  </b>
                </apex:column>
                <!--apex:column value="{!oli.APT_Product__c}" headerValue="Product" /--> 
                <apex:column headerValue="Classification">                
                <apex:inputField value="{!oli.APT_Classification__c}" id="classID" />
                </apex:column>
</apex:pageBlockTable>

public void cloneEntry(){
    
          Integer entryToClone= integer.valueof(Apexpages.currentPage().getParameters().get('entryToClone'));                      
          APT_Opportunity_Product_Line_Item__c opToClone= new APT_Opportunity_Product_Line_Item__c();         
           opToClone= lstEntries[entryToClone];                    
           opToClone.APT_Sequence_Number__c= lstEntries.size();
          lstEntries.add(opToClone);      
         
    }



I have tried multiple scenarios on the method no success.

Please suggest me whats going wrong here.

Thanks in advance.