You need to sign in to do that
Don't have an account?
SURESH MINGANI
SOQL to fetch Tasks that are assinged on a Particular Account
Hi
I need to display on vf by SOQL to fetch Tasks that are assinged on a Particular Account
I need to display on vf by SOQL to fetch Tasks that are assinged on a Particular Account
//Controller code
//replace my whatid with yours.
public class accountTaskController{
List<Task> lstOfTasks = new List<Task>();
public string accountname {get;set;}
public List<Task> getAccountTasks()
{
return lstOfTasks;
}
public PageReference getListOfTasks()
{
lstOfTasks = [SELECT id,createddate, subject FROM Task WHERE whatId = '0017F00000Ge0WD'];
return null;
}
}
//Vf Page
<apex:page controller="accountTaskController">
<apex:form>
<apex:pageBlock>
<apex:commandButton action="{!getListOfTasks}" value="Show Tasks"/>
</apex:pageBlock>
<apex:pageBlock title="Tasks for Account">
<apex:pageBlockTable value="{!AccountTasks}" var="task">
<apex:column value="{!task.Id}"/>
<apex:column value="{!task.subject}"/>
<apex:column value="{!task.CreatedDate}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
After Clicking Show task button here are the related tasks.
Kindly mark my answer, if it helps you.
Thanks,
Hasan Shamsi
All Answers
//Controller code
//replace my whatid with yours.
public class accountTaskController{
List<Task> lstOfTasks = new List<Task>();
public string accountname {get;set;}
public List<Task> getAccountTasks()
{
return lstOfTasks;
}
public PageReference getListOfTasks()
{
lstOfTasks = [SELECT id,createddate, subject FROM Task WHERE whatId = '0017F00000Ge0WD'];
return null;
}
}
//Vf Page
<apex:page controller="accountTaskController">
<apex:form>
<apex:pageBlock>
<apex:commandButton action="{!getListOfTasks}" value="Show Tasks"/>
</apex:pageBlock>
<apex:pageBlock title="Tasks for Account">
<apex:pageBlockTable value="{!AccountTasks}" var="task">
<apex:column value="{!task.Id}"/>
<apex:column value="{!task.subject}"/>
<apex:column value="{!task.CreatedDate}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
After Clicking Show task button here are the related tasks.
Kindly mark my answer, if it helps you.
Thanks,
Hasan Shamsi
Sumit Kumar Singh & Shamsi