2

I have a controller which I use to get all calls that were made against all Opportunities against an Account Object.

public with sharing class getOppCallsController {

private Id accountId;
public List<Task> oppCalls {get;set;}

public getOppCallsController (ApexPages.StandardController sc) {
    accountId = sc.getId();
    oppCalls = new List<Task>();
}

public Task[] getOppCalls() {
    if (accountId != null) {
        return oppCalls = [
                select Id, Subject
                from Task
                where WhatId in (select Id from Opportunity where AccountId = :accountId)
                and Type = 'Call'
                ];
    } else {
        return new Task[] {};
    }
}

}

Now I want to create a Visualforce page which displays these calls.

Opportunity Name | Call Subject | Call Date (or similar to that)

I have written the following, just to do a bit of testing, because I am new to this, but I seem to already fail right in the beginning.

  <apex:page standardController="Account" extensions="getOppCallsController">
  <apex:repeat value="{!oppCalls.Subject}">
  </apex:repeat>
  </apex:page>

I get the error: Error: Unknown property 'VisualforceArrayList.Subject'

Not sure what to do next. Tia.

1 Answer 1

1

You will need to use Var attribute of repeater to access object elements ,here is how repeat tag is handled in VF

<apex:repeat value="{!oppCalls}" var="act">
   {!act.Subject}
  </apex:repeat>

While this is just demonstration but should help you to understand how an iteration of collection is done at front end in visualforce.Also your query will be on opportunity I believe and then from opportunity you want to access activity.

3
  • Hello, Unfortunately I tried that and I amended it to fit into my table, but it doesn't work. <apex:page standardController="Account" extensions="getOppCallsController"> <h1>Logged calls against opps</h1> <table> <apex:repeat value="{!oppCalls}" var="oc"> <tr> <td>This is the subject {!oc.Subject}</td> </tr> </apex:repeat> </table> </apex:page>
    – Lily
    Commented Nov 13, 2014 at 19:51
  • If your query returns rows there is no way this should fail .Check your query returns rows .Also you will need proper account id in url with id=AccountId Commented Nov 13, 2014 at 20:07
  • how can I check whether my query returns rows?
    – Lily
    Commented Nov 14, 2014 at 14:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .