You need to sign in to do that
Don't have an account?
Rakesh K 60
Unknown error in my VF page and there is no Error Statement
Hi,
I'm trying to create a VF page that will listdown all the Tasks related to current Account and here is my VF code.
And my Controller is as below.
When I run this, I get the error as below.
Can someone please let me know where I went wrong?
And I apologise if there are is any silly mistake. I'm new to VF, U started my journey with Lightning.
Thanks
I'm trying to create a VF page that will listdown all the Tasks related to current Account and here is my VF code.
<apex:page standardController="Account" extensions="MyCustomController" > <apex:form > <apex:pageBlock id="pb"> <apex:pageBlockTable value="{!TaskList}" var="d"> <apex:column headerValue="Subject"> <apex:outputField value="{!d.Subject}"> </apex:outputField> </apex:column> </apex:pageBlockTable> </apex:pageblock> </apex:form> </apex:page>
And my Controller is as below.
public class MyCustomController { Public List<SObject> TaskList{get;set;} String currentRecordId ; public MyCustomController(ApexPages.StandardController controller) { TaskList= new List<SObject>(); currentRecordId = ApexPages.CurrentPage().getparameters().get('id'); System.debug(currentRecordId); List<Contact> cts = [Select Id, Name from Contact where AccountId=:currentRecordId]; List<sObject> events = new List<sObject>(); for(Contact c: cts){ List<Task> tskL = [Select Id, Subject from Task where whoId=:c.Id order by ActivityDate desc]; for(Task t: tskl){ events.add(t); } List<Event> evtL = [Select Id, Subject from Event where whoId=:c.Id order by ActivityDate desc]; for(Event e: evtL){ events.add(e); } } TaskList = events; System.debug(TaskList); } }
When I run this, I get the error as below.
Can someone please let me know where I went wrong?
And I apologise if there are is any silly mistake. I'm new to VF, U started my journey with Lightning.
Thanks
currentRecordId = (Account)controller.getRecord().id;
with ApexPages.CurrentPage().getparameters().get('id');
it tries to get value from parameter id in the url, like
https://xxxxx.salesforce.com?id=001xxxxxxxxxxxxxxxx
The problem is in below line:
<apex:outputField value="{!d.Subject}"> --> wrong one
<apex:outputField value="{!d['Subject']}"> --> Correct Way:
While iterating the Sobject you have use the fields expressions as value="{!d['Subject']}" . Don't use the normal way of data binding it will not work.
Update VF Page:
Thanks,
Maharajan.C