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 refresh the page through visualforce

Hi everyone
My scenario is to show the open task of lead object as a seperate related list instead of using open activity.
For that i took viusalforce and extension controller.
It works good actually.
when clicking  the close button and check box the particular record will get closed but the thing is 
its not showing in Activity History immediatly after refreshing the page only its shows that particular record in Activity History.
can anyone help me out to solve thing problem..
public class OpenTasks {

    public List<OpenActivity> open{get;set;}

    public Id leadLd{get;set;}
   
    public list<wrapperclass> listwrapper{get;set;}
    

    public OpenTasks(ApexPages.StandardController controller){

        leadLd = ApexPages.CurrentPage().getparameters().get('id');
        list<task> open1 =new list<Task>();

        listwrapper = new list<wrapperclass>();
         


        list<lead>   le =[SELECT Name, (Select Id,Subject, WhoId, ActivityDate,Status, Priority, OwnerId FROM Tasks WHERE IsClosed=false)

                            FROM Lead WHERE Id = :leadld];

        if(!le.isEmpty()){
            
            for(Task k: le[0].Tasks)

            {

               listwrapper.add(new Wrapperclass(k));
               
            }

        }

    }

     

    public class wrapperclass

    {
        public  boolean checked{get;set;}

        public Task k{get;set;}

        public Wrapperclass(Task k){

            this.k=k;

        }

    }

  public PageReference close()

    {  

        list<Task> listofopen=new list<Task>();

        if(!listwrapper.isEmpty()){

            for(Integer i=0; i<listwrapper.size();i++)

            {
                wrapperclass w = listwrapper[i];
           
                if(w.checked==true){
                    system.debug(w);
                    w.k.status='completed';
                    listofopen.add(w.k);
                    listwrapper.remove(i);
                    i--;
   
                                }
             
            }

        }

        if(listofopen.isEmpty())

        {

            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Select atleast one column '));

        }

        else{

           update listofopen;   

        }
       
    
  
      return null;

    }  

 }

visualforce

<apex:page standardController="Lead" extensions="OpenTasks"  >

    <apex:form >

        <apex:pageBlock title="Open Tasks" mode="edit" id="opnTsks">

            <apex:Messages />        

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

                <apex:commandButton value="close" action="{!close}" rerender="opnTsks" />

            </center>&nbsp;&nbsp;

            <apex:pageBlockTable value="{!listwrapper}" var="each" >

                <apex:column headerValue="Action">

                     <apex:inputCheckbox value="{!each.checked}"/>

                    &nbsp;|&nbsp;

                    <apex:outputlink value="/{!each.k.id}/e?retURL={!each.k.WhoId}" target="_top"> Edit </apex:outputlink>

                   </apex:column>

                <apex:column headerValue="Subject" value="{!each.k.Subject}"/>

                <apex:column headerValue="ActiveDate" value="{!each.k.ActivityDate}"/>

                <apex:column headerValue="Status" value="{!each.k.Status}"/>

            </apex:pageBlockTable>

        </apex:pageBlock>

     </apex:form>

</apex:page>
Thank you in advance...
 
Best Answer chosen by shobana shobana
Bhanu MaheshBhanu Mahesh
Hi Shobana,

Refer the below link it may help you
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000972tIAA

Regards,
Bhanu Mahesh

All Answers

Bhanu MaheshBhanu Mahesh
Hi Shobana,

Refer the below link it may help you
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000972tIAA

Regards,
Bhanu Mahesh
This was selected as the best answer
shobana shobanashobana shobana
Hi Bhanu Mahesh
Thank you for helping me.Its working good.