You need to sign in to do that
Don't have an account?
mohit tripathi
Visualforce Extension ISsue
Hi Guys,
I am getting following error when I am trying to fetch opportunities which I have already fetched in another method.
HEre is my Extension-
public class StandardControllerExtension {
public Account Acct;
public StandardControllerExtension(ApexPages.StandardController stdController) {
Acct= (Account)stdController.getRecord();
}
Public List<Opportunity> getoppt(){
return [ select name, stageName , Amount , CloseDate From Opportunity where AccountID =:acct.Id and ( LeadSource = 'Web' And StageName= 'Prospecting')];
}
public void CreateTaskOnChildOppt(){
List <Task> newtask = new List<task>();
for (Opportunity opp : oppt) {
if(!opp.isclose){
newtask.add(
new Task(
WhatId = opp.Id,
OwnerId = opp.OwnerId,
ActivityDate = Date.today() + 3,
Subject = 'Send follow-up email to primary contact'));
}
}
if (newtask.size() > 0) insert newtask;
}
public pageReference Save(){
if(Acct.Rating=='Hot'){
CreateTaskOnChildOppt();
}
update Acct;
Return new PageReference('/' + Acct.id);
}
}
Error-Error: StandardControllerExtension Compile Error: Variable does not exist: oppt at line 15 column 33
Highlighted them for the reference.
Thanks in advance
I am getting following error when I am trying to fetch opportunities which I have already fetched in another method.
HEre is my Extension-
public class StandardControllerExtension {
public Account Acct;
public StandardControllerExtension(ApexPages.StandardController stdController) {
Acct= (Account)stdController.getRecord();
}
Public List<Opportunity> getoppt(){
return [ select name, stageName , Amount , CloseDate From Opportunity where AccountID =:acct.Id and ( LeadSource = 'Web' And StageName= 'Prospecting')];
}
public void CreateTaskOnChildOppt(){
List <Task> newtask = new List<task>();
for (Opportunity opp : oppt) {
if(!opp.isclose){
newtask.add(
new Task(
WhatId = opp.Id,
OwnerId = opp.OwnerId,
ActivityDate = Date.today() + 3,
Subject = 'Send follow-up email to primary contact'));
}
}
if (newtask.size() > 0) insert newtask;
}
public pageReference Save(){
if(Acct.Rating=='Hot'){
CreateTaskOnChildOppt();
}
update Acct;
Return new PageReference('/' + Acct.id);
}
}
Error-Error: StandardControllerExtension Compile Error: Variable does not exist: oppt at line 15 column 33
Highlighted them for the reference.
Thanks in advance
All Answers
Thanks for the reply but I have tried that and getting following error.
Error: StandardControllerExtension Compile Error: Variable does not exist: getoppt at line 18 column 33
I made the changes suggested by you and it is working perfectly fine..
Thanks a ton Man .. Cheers
When I Am trying to this via custom controller, I Am unable to fetch contact's record from an account in vf page.
I feel controller is fine but I Am missing something in VF page.
Here is my controller-
public class AccCustomOppController {
Public Account Acct {get; set;}
public AccCustomOppController (){
String AcctId = ApexPages.CurrentPage().getParameters().get('id');
Acct= [select name, Rating, id from Account Where Id =: AcctId];
}
public List<Contact> ContactList{
get{
ContactList = [ select name, Email , Department from Contact where AccountId = :Acct.Id ];
return ContactList;
}
set;
}
Public PageReference Save(){
update Acct;
return new pageReference ('/' + Acct.ID);
}
}
and VF page is-
<apex:page controller="AccCustomOppController">
<apex:form >
<apex:pageblock Title="Account Custom Controller check">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save the updated Account Information"/>
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:inputField value="{!Acct.Name}"/>
</apex:pageBlockSection>
</apex:pageblock>
<apex:pageBlock>
<apex:pageBlockTable value="{!ContactList}" var="Con">
<apex:column value="{!con.Name}" title="Contact Name"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Can you please have a look into this?
Thanks in advance