You need to sign in to do that
Don't have an account?
shobana shobana
how to show the open task as separate related list for lead in pagelayout?
Hi everyone
This is my first wrapper class.
I would like to show open task as seperate section on my lead page layout.
For that i took a standard controller with extension.In this scenario i have finished upto 3steps and I got output also.
Step 1; showing task record related to lead object.
Step 2:i have created new task button.
Step 3: i have show edit option for each records of task.
My 3rd and 4th step is to add a checkbox and close button for that section.whenever am clicking checkbox and close botton i want to show that particular record in activity history.
for this concept i took wrapper class concept but its showing error " opentasks Compile Error: Variable does not exist: status
can anyone help me out
Thank you in advance
This is my first wrapper class.
I would like to show open task as seperate section on my lead page layout.
For that i took a standard controller with extension.In this scenario i have finished upto 3steps and I got output also.
Step 1; showing task record related to lead object.
Step 2:i have created new task button.
Step 3: i have show edit option for each records of task.
My 3rd and 4th step is to add a checkbox and close button for that section.whenever am clicking checkbox and close botton i want to show that particular record in activity history.
for this concept i took wrapper class concept but its showing error " opentasks Compile Error: Variable does not exist: status
my controller page public class opentasks { public List<OpenActivity> open{get;set;} public Id leadld{get;set;} Public boolean allbool{get;set;} public list<wrapperclass> listwrapper{get;set;} public list<lead> c{get;set;} public opentasks(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; } } public opentasks(){ list<openactivity> open1 =new list<openactivity>(); list<lead> le =[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){ open1 = c[0].OpenActivities; } for(Openactivity k:open1) { listwrapper.add(new Wrapperclass(k)); } } public class wrapperclass { public boolean checked{get;set;} public Openactivity k{get;set;} public Wrapperclass(openactivity k) { this.k=k; } } public void close() { list<openactivity> listofopen=new list<openactivity>(); list<wrapperclass> listofwrapper=new list<wrapperclass>(); for(wrapperclass w:listwrapper) { if(w.checked==true) { system.debug(w); w.status='completed'; HERE AM GETTING ERROR listofopen.add(w.k); } else { listofwrapper.add(w); } } if(listofopen.size()==0) { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Select atleast one column t')); }} }
can anyone help me out
Thank you in advance
Try the below code
VF Page
Extension
Hope it may help you
Regards,
Bhanu Mahesh
All Answers
Hi Shobana,
You should acces it using w.k.Status because Status is in OpenActivity which is an attribute of Wrapper class
But you cannot update OpenActivity object. It is Read Only object.
Please refer the below link
https://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_openactivity.htm
https://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_openactivity.htm
So Intead of fetching records from OpenActivity, fetch the records from task Object and display it in the Vf page and then you can update the task records
Your SOQL Query will be
list<lead> le =[SELECT Name, (Select Id,Subject,IsTask, WhoId, ActivityDate, Status, Priority, OwnerId FROM Tasks WHERE isClosed = false) FROM Lead WHERE Id = :leadld];
Please provide your vf page if possible
Regards,
Bhanu Mahesh
You need to change w.status to k.status. Since In OpenActivity you have a field Status. But in you just refering the status field with Wrapper instance, that why you are getting error.
Take a look on the below example, it will be helpful to you,
https://developer.salesforce.com/page/Checkbox_in_DataTable
I have changed my code still am getting same error
can anyone please help be out
Thank you
Try the below code
VF Page
Extension
Hope it may help you
Regards,
Bhanu Mahesh
In your code there is space between w and k. So remove the space w.k.Status='completed'; and try it.
After that you code get saved to me.
Arunkumar Actually i am getting error as" Variable does not exist: Status "
Thank you for sending me code Banu mahesh, actually i have tried your code but showing error in 13th line as Loop variable must be an SObject or list of Task .
It is working fine in my trial org.
As you can see that the iteration is over the Task list.
Might be the error because you have a class in your org with name 'task'. So please change that class name and try again.
Regards,
Bhanu Mahesh
Thank you its working ..
But the thing is when am selecting bulk record its closing only two record.If am again selecting bulk records only one record geting close.
Add i--; in the if of close() after this statement listwrapper.remove(i);
if(w.checked==true){
system.debug(w);
w.k.status='completed';
listofopen.add(w.k);
listwrapper.remove(i);
i--;
}
Try now. It should work.
Previously it is not iterating through all the records as I am removing the record from list and checking with size, It is iterating through all the records. Now it will.
Regards,
Bhanu Mahesh
Thanks a lot its working...