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
shobana shobanashobana shobana 

how to close the task of lead object on the same page without using java script and any scripting language.

hi everyone
My scenario is to while clicking the checkbox and close button i want to close the list of record of open task in lead object and it  should  be  store  in Activity history related list.
can anyone give me  guidence to solve this scenario.
I have wrote code for geting
1.New Task button
2.Related task record of lead object.
3.Edit operation for exiting task record of lead object.
I have got output for above 3 steps.
 my 4th step is while clicking the checkbox  and close button i want to close the list of record of open task in lead object and it  should  be  store  in Activity history related list.
 

public class k {
public List<OpenActivity> open{get;set;}
    public Id leadld{get;set;}
    public list<lead> c{get;set;}
    public k(ApexPages.StandardController controller) {
        leadld = ApexPages.CurrentPage().getparameters().get('id');
         c =[SELECT Name, 
                                  (Select Id,Subject,IsTask, WhoId, ActivityDate,
                                    Status, Priority, OwnerId FROM OpenActivities WHERE IsTask=True) 
                            FROM Lead WHERE Id = :leadld];
        if(c.size() > 0){
            open = c[0].OpenActivities;
        }
        
        }
    
                             
        
     
    
    
}

visualforce page:
<apex:page standardController="Lead" extensions="k" >
    <apex:form >
        <apex:pageBlock >
            


<center><a href="https://ap1.salesforce.com/00T/e?who_id={!leadld}&retURL={!leadld}" target="_top"><button type="button">New Task</button></a>
</center>

                <apex:pageBlockTable value="{!open}" var="each"   >
                <apex:column headerValue="Action">
                <apex:outputlink value="/{!each.id}/e?retURL={!each.WhoId}" target="_top"> Edit </apex:outputlink>
                   </apex:column>
                <apex:column headerValue="Subject" value="{!each.Subject}"/>
                <apex:column headerValue="ActiveDate" value="{!each.ActivityDate}"/>
                <apex:column headerValue="Status" value="{!each.Status}"/>
                </apex:pageBlockTable>
            </apex:pageBlock>
     </apex:form> 
</apex:page>