• mohit tripathi
  • NEWBIE
  • 40 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 18
    Replies
Hi Team,

So I am trying to update a checkbox field as true or false based on quarter but unable to do so.
Can anybody please check this code and tell me where i am wring?

public class Customerecommendedcontroller {


Set<Integer> Q1 = new Set<Integer>{1,2,3};
 Set<Integer> Q2 = new Set<Integer>{4,5,6};
Set<Integer> Q3 = new Set<Integer>{7,8,9};
 Set<Integer> Q4 = new Set<Integer>{10,11,12};
public Account ac;
  integer cMonth= date.today().month();
  Public List<recommended_Steps__c> totestList{get;set;}
  public List<recommended_Steps__c> lstForUpdate = new list<recommended_Steps__c>();
  public Customerecommendedcontroller(ApexPages.StandardController controller) {
       ac=(Account)controller.getrecord();
   }
   public  list<recommended_Steps__c> recomn{
 get{
 totestList = [select  Check__c, Account__c,Quarter__c,Due_date__c,Current_Quarter__c,Steps_to_taken__c,Subject__c,recommended_Steps__c.Sprint__r.End_Date__c from recommended_Steps__c where Account__r.id = :ac.id];
 for(recommended_Steps__c rc : totestList ){
 if(Q1.contains(cMonth))
{
    rc.Current_Quarter__c = 'Q1';
    if(rc.Quarter__c == rc.Current_Quarter__c){
      rc.Check__c = true ;

    }
    else{
    rc.Check__c= false;
    }
   
  }
  if(Q2.contains(cMonth))
{
    rc.Current_Quarter__c = 'Q2';
    if(rc.Quarter__c== rc.Current_Quarter__c){
      rc.Check__c = true ;

    }
    else{
    rc.Check__c= false;
    }

   
  }
if(Q3.contains(cMonth))
{
    rc.Current_Quarter__c = 'Q3';
    if(rc.Quarter__c== rc.Current_Quarter__c){
      rc.Check__c = true ;

    }
    else{
    rc.Check__c= false;
    }

   
  }
if(Q4.contains(cMonth))
{
    rc.Current_Quarter__c = 'Q4';
    if(rc.Current_Quarter__c == rc.Quarter__c){
      rc.Check__c = true ;

    }
    else{
    rc.Check__c= false;
    }

   
  }

lstForUpdate.add(rc);

 }
 update totestList ;
 update lstForUpdate;
  return totestList ;
 }
 
 
 set{}
 }
 }

Hi Guys,

 

Can anybody please tell me why I am getting this error:

Error: Customerecommendedcontroller Compile Error: Expecting '}' but was: 'for' at line 14 column 1

Controlller is as follows-

public class Customerecommendedcontroller {

 public Account ac;
 integer Quarter = Date.Today().Month()/3;
Public List<recommended_Steps__c> totestList{
get{
List<recommended_Steps__c> totestList= [select Quarter__c from recommended_Steps__c where Account__r.id = :ac.id];
retrun totalList;
}
set{}

}

for(recommended_Steps__c rc : totestList )
{
if(Quarter == Quarter__c){
Check__c = true;
}
else

Check__c = false;

 }
 update rc;
 totestList.add(rc);
 
 public list<recommended_Steps__c> recom{
 get{
 List<recommended_Steps__c> recom = [select id,     Account__c,Due_date__c,Steps_to_taken__c,Subject__c,recommended_Steps__c.Sprint__r.End_Date__c  from recommended_Steps__c where Account__r.id = :ac.id and Check__c= true];
 return recom;
 }
 set{
 }
 
 
 }
 
 

    public Customerecommendedcontroller(ApexPages.StandardController controller) {
       ac=(Account)controller.getrecord();
    }

}

Thanks in Advance :)

Suppose I have a very basic trigger on contact which updates  Department and I have few system.debug lines on my code.
I have updated a contact in salesforce and now want to see that system.debug line but how to check that.How to Open the log for your latest action?

I can see execute anonymous , but I have already updated a contact in salesforce so Was I suppose to do that from here or what?
Please help me to understand this.

 

Thanks in Advance

Hi Guys, 

I am new to salesforce and it would be great if you can help me.

I am trying to initialize a list of account inside constructor but getting following error-


Error: accounttestclss Compile Error: Illegal assignment from List<Account> to List<Account> at line 7 column 6

Here is the controller=

public class accounttestclss {

public list<Account> Accont{get; set;}

    public accounttestclss(ApexPages.StandardSetController controller) {

     Accont= [select name , rating from Account limit 10];
 
    }



Thanks in advance
Hi Guys

When I Am trying to fetch contact's Record from Account 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>


Please let me know what am I doing Wrong.


Thanks in Advance
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

Hi Guys,

 

Can anybody please tell me why I am getting this error:

Error: Customerecommendedcontroller Compile Error: Expecting '}' but was: 'for' at line 14 column 1

Controlller is as follows-

public class Customerecommendedcontroller {

 public Account ac;
 integer Quarter = Date.Today().Month()/3;
Public List<recommended_Steps__c> totestList{
get{
List<recommended_Steps__c> totestList= [select Quarter__c from recommended_Steps__c where Account__r.id = :ac.id];
retrun totalList;
}
set{}

}

for(recommended_Steps__c rc : totestList )
{
if(Quarter == Quarter__c){
Check__c = true;
}
else

Check__c = false;

 }
 update rc;
 totestList.add(rc);
 
 public list<recommended_Steps__c> recom{
 get{
 List<recommended_Steps__c> recom = [select id,     Account__c,Due_date__c,Steps_to_taken__c,Subject__c,recommended_Steps__c.Sprint__r.End_Date__c  from recommended_Steps__c where Account__r.id = :ac.id and Check__c= true];
 return recom;
 }
 set{
 }
 
 
 }
 
 

    public Customerecommendedcontroller(ApexPages.StandardController controller) {
       ac=(Account)controller.getrecord();
    }

}

Thanks in Advance :)

Hi Guys, 

I am new to salesforce and it would be great if you can help me.

I am trying to initialize a list of account inside constructor but getting following error-


Error: accounttestclss Compile Error: Illegal assignment from List<Account> to List<Account> at line 7 column 6

Here is the controller=

public class accounttestclss {

public list<Account> Accont{get; set;}

    public accounttestclss(ApexPages.StandardSetController controller) {

     Accont= [select name , rating from Account limit 10];
 
    }



Thanks in advance
Hello, 

We have an input screen which updates data after clicking on 'Next'. In the next screen the value entered in the previous screen is shown. 
The first time I enter data and click on 'next' the value is saved and displayed correctly. However, if i click on 'Previous', update the value and then click on 'Next' again, the value is not updated with the new one but remains with the old value. 
I think its a Salesforce issue, anyone encountered this and any workaround or fix in view?

Thanks
Nawshine
Recently started working on more Trailheads.  Are they only available in Lightning Experience now?  We are still using Classic for our org.
Hi Guys

When I Am trying to fetch contact's Record from Account 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>


Please let me know what am I doing Wrong.


Thanks in Advance
Hello I have a salesforce to salesforce connection between two orgs and I am trying to sending opportunity products from the publishing org to the target org. I created a replica pricebook on the target org, but the products don't seem to be transferring over. 

Is it possible to send a pricebook directly from one org to the other? If not, how have others gotten around the issue? Thank you
  • July 26, 2017
  • Like
  • 0
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