You need to sign in to do that
Don't have an account?
Behzad Bahadori 18
Trying to display the current Users Opportunities in the page
HI I have the following code but i get an error. I dont know why I cant show the recent opportunities
public with sharing class OppExt {
public List<Opportunity> myOpportunities { get; private set; }
public OppExt(){
myOpportunities = [ SELECT Id, Name, Account.Name
from Opportunity
WHERE OwnerId = :UserInfo.getUserId()];
}
//Set<Opportunity> ids = new Set<Opportunity>();
public List<Opportunity> getOpp() {
System.debug(myOpportunities);
return myOpportunities;
}
}
Apex page
<header>
<div class="container">
<div class="intro-text">
<a href="#services" class="page-scroll btn btn-xl">Create New Opportunity</a>
<a href="#services" class="page-scroll btn btn-xl">Add to Existing Opportunity</a>
<a href="#services" class="btn-custom">Add to Existing Opportunity</a>
<div class = "span4">
<button class="btn custom large f" >Foxtrot</button>
</div>
</div>
<apex:outputText value="{!$User.Id}"/>
<apex:outputText value="{!$User.FirstName}"/>
<apex:outputText value="{!$User.LastName}"/>
<!-- <apex:outputfield value="{!currentuser.Id}"/> -->
<apex:repeat >
<apex:outputText value="{!myOpportunities.Name}"/>
</apex:repeat>
</div>
</header>
</apex:page>
public with sharing class OppExt {
public List<Opportunity> myOpportunities { get; private set; }
public OppExt(){
myOpportunities = [ SELECT Id, Name, Account.Name
from Opportunity
WHERE OwnerId = :UserInfo.getUserId()];
}
//Set<Opportunity> ids = new Set<Opportunity>();
public List<Opportunity> getOpp() {
System.debug(myOpportunities);
return myOpportunities;
}
}
Apex page
<header>
<div class="container">
<div class="intro-text">
<a href="#services" class="page-scroll btn btn-xl">Create New Opportunity</a>
<a href="#services" class="page-scroll btn btn-xl">Add to Existing Opportunity</a>
<a href="#services" class="btn-custom">Add to Existing Opportunity</a>
<div class = "span4">
<button class="btn custom large f" >Foxtrot</button>
</div>
</div>
<apex:outputText value="{!$User.Id}"/>
<apex:outputText value="{!$User.FirstName}"/>
<apex:outputText value="{!$User.LastName}"/>
<!-- <apex:outputfield value="{!currentuser.Id}"/> -->
<apex:repeat >
<apex:outputText value="{!myOpportunities.Name}"/>
</apex:repeat>
</div>
</header>
</apex:page>
In your visualforce page your repeat is not setup to loop through the list. You need to use the "value" and "var" attributes.
Try this:
Controller:
Visualforce:
Hope that helps,
Clint
All Answers
In your visualforce page your repeat is not setup to loop through the list. You need to use the "value" and "var" attributes.
Try this:
Controller:
Visualforce:
Hope that helps,
Clint