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
Akanksha sharma 15Akanksha sharma 15 

when i will check the checkbox and when click on clone that selected records should be clone and update on related list of opportunity my concern is all records are being duplicated

When i click on clone and study button that is present on related list of opportunity a new page should be open where i can see all related records of object study  and case (with checkbox)and when i will  click on clone button  that selected records should be clone on related list.But  what happened with my code all records being clone on related list i need to clone only selected records.
Mu concern is i am not able to use  selected checkbox in a query to update selected records. can anyone help me

<
<apex:page standardController="Opportunity" extensions="stucasecontroller">
   <apex:form >
   <apex:pageBlock title="relatedlist details">
   
   <apex:pageblockSection title="case realted list ">
   <apex:pageBlocktable value="{!cas}" var="c" >
   <apex:column headervalue="Action">
<apex:inputcheckbox />
</apex:column>
   <apex:column value="{!c.status}"/>
   <apex:column value="{!c.origin}"/>
   </apex:pageblocktable>
   </apex:pageblockSection>
   
   <apex:pageBlockSection title="Study relatedlist">
   <apex:pageBlocktable value="{!stu}" var="s" >
   <apex:column headervalue="Action">
<apex:inputcheckbox />
</apex:column>
   <apex:column value="{!s.Name}"/>
   <apex:column value="{!s.Rollno__c}"/>
   </apex:pageblocktable>
   </apex:pageblockSection>   
   </apex:pageBlock>
   
   <apex:commandButton value="clone on relatedlist" action="{!relatedlistclone}"/>
  </apex:form>
</apex:page>


public class stucasecontroller {

public List<case> cas{get;set;}
public List<study__c> stu{get;set;}

    public stucasecontroller(ApexPages.StandardController controller) {
    String oppID='0060K00000RZfqbQAD';
    cas=[select Id,status,origin,opportunity__r.Name,opportunity__c  from case where opportunity__c=:oppID];
   string stuid='0060K00000RZfqbQAD';
  stu=[select Name,Rollno__c,opportunity__r.Name from study__c where opportunity__c=:stuid];
   

    }


    public PageReference relatedlistclone() {
       List<case> cas=[select Id,status,origin,opportunity__r.Name,opportunity__c  from case where opportunity__c='0060K00000RZfqbQAD' and Action='True'];
         List<study__c> stu=[select Name,Rollno__c,opportunity__r.Name from study__c where opportunity__c='0060K00000RZfqbQAD'];
         List<case> cloneList=cas.deepclone();
         List<study__c> stulidt=stu.deepclone();
        insert cloneList;
        insert stulidt;
        pagereference pr = new pagereference('https://c.ap6.visual.force.com/apex/relatedopp?id=0060K00000RZfqb');  
        return pr;
        
    }




    

}