• Heena.
  • NEWBIE
  • 0 Points
  • Member since 2017
  • Junior Salesforce Developer
  • Barclays


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 6
    Replies
We couldn't find a dashboard named 'My Account and Contact Dashboard'. this error is shown me again and again plz help me outi followed all the steps as per trailhead even then i am facing problem
i m facing problem in further step that after pressing this buttons it should do this following work
* Save and log Email - save data and open Email logging screen without interaction component.
* Save and log SMS - save data and open SMS logging screen without interaction component.
i am doing this in lightning, i know that i have write a method for this but i am new to developing field.
plz can anyone share me the method for both {component and controller}
  • December 24, 2018
  • Like
  • 0
 
<--------------------------------------------------------------------------------- APEX CODE ------------------------------------------------------------------>

public class confirmButtonCtrl {
  
    public confirmButtonCtrl(){
        
    }
    
    public void converLeadMethod(){
       string recId=ApexPages.currentPage().getParameters().get('id');
      lead l=[select id,status from lead where id=:recId ];
        if(l.status!='Ready to Convert'){
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.Error,'You cant covert lead until the status is Ready to Convert');
            ApexPages.addMessage(msg);
        }else{
            Database.LeadConvert lc = new database.LeadConvert();
            lc.setLeadId(l.Id);
            lc.setDoNotCreateOpportunity(false);
            LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
            lc.setConvertedStatus(convertStatus.MasterLabel);
          
            Database.LeadConvertResult lcr = Database.convertLead(lc);
            if(lcr.isSuccess()){
                ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.Confirm,'Lead Converted Successfully');
                ApexPages.addMessage(msg);
            }else{
                String[] messages = new String[0];
                for(Database.Error error: lcr.getErrors()) {
                    messages.add(error.getMessage());
                }
              
               
                    ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.Error,messages[0]);
                    ApexPages.addMessage(msg);
                
                
            }
            
           
            
           
        } 
    }

}




<------------------------------------------------------------------------------------------ VISUALFORCE PAGE --------------------------------------------------------------------------------->


<apex:page Controller="confirmButtonCtrl" action="{!converLeadMethod}">
    <apex:pageBlock >                                            
    <apex:pageMessages id="msgId"/>
</apex:pageBlock>
</apex:page>
  • October 11, 2018
  • Like
  • 0
<apex:page controller="wrapperClassController">
 <apex:form >
  <apex:pageBlock >
      
  <apex:pageBlockSection>
          
   </apex:pageBlockSection>
      
      
   <apex:pageBlockButtons >
     <apex:commandButton value="send survey" action="{!sendsurvey}" rerender="table"/>
   </apex:pageBlockButtons>
                <!-- In our table we are displaying the cContact records -->
         <apex:pageBlockTable value="{!contacts}" var="c" id="table">
            <apex:column >
              <!-- This is our selected Boolean property in our wrapper class -->
           <apex:inputCheckbox value="{!c.selected}"/>
           </apex:column>
             <!-- This is how we access the contact values within our cContact container/wrapper -->
           <apex:column value="{!c.con.Name}" />
           <apex:column value="{!c.con.Email}" />
           <apex:column value="{!c.con.Phone}" />
      </apex:pageBlockTable>
    </apex:pageBlock>
  </apex:form>

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

public class wrapperClassController {

    
        //Our collection of the class/wrapper objects cContact
        public List<cContact> contactList {get; set;}
    
        //This method uses a simple SOQL query to return a List of Contacts
        public List<cContact> getContacts() {
            if(contactList == null) {
                contactList = new List<cContact>();
                for(Contact c: [select Id, Name, Email, Phone from Contact limit 10]) {
                    // As each contact is processed we create a new cContact object and add it to the contactList
                    contactList.add(new cContact(c));
                }
            }
            return contactList;
        }
         
        public PageReference sendsurvey() {    
                    //We create a new list of Contacts that we be populated only with Contacts if they are selected
            List<Contact> selectedContacts = new List<Contact>();


            //We will cycle through our list of cContacts and will check to see if the selected property is set to true, if it is we add the Contact to the selectedContacts list

            for(cContact cCon: getContacts()) {

                if(cCon.selected == true) {
                    selectedContacts.add(cCon.con);
                }
            }
    
            // Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc
            System.debug('These are the selected Contacts...');
            for(Contact con: selectedContacts) {
                system.debug(con);
            }
            contactList=null; // we need this line if we performed a write operation  because getContacts gets a fresh list now
            return null;
        }
    
    
        // This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value
        public class cContact {
            public Contact con {get; set;}
            public Boolean selected {get; set;}
    
            //This is the contructor method. When we create a new cContact object we pass a Contact that is set to the con property. We also set the selected value to false
            public cContact(Contact c) {
                con = c;
                selected = false;
            }
        }
    }
  • September 22, 2018
  • Like
  • 0
public class Tpactivities {
  public list<contact> cons{set;get;}
  
    public Tpactivities (){
     cons = [select id, firstname, lastname from contact];
    }

    public PageReference getfeedback() {
     cons = [select id, firstname, lastname from contact];
        return null;
    }

}
  • September 18, 2018
  • Like
  • 0
<apex:page controller="wrapperClassController">
 <apex:form >
  <apex:pageBlock >
      
  <apex:pageBlockSection>
          
   </apex:pageBlockSection>
      
      
   <apex:pageBlockButtons >
     <apex:commandButton value="send survey" action="{!sendsurvey}" rerender="table"/>
   </apex:pageBlockButtons>
                <!-- In our table we are displaying the cContact records -->
         <apex:pageBlockTable value="{!contacts}" var="c" id="table">
            <apex:column >
              <!-- This is our selected Boolean property in our wrapper class -->
           <apex:inputCheckbox value="{!c.selected}"/>
           </apex:column>
             <!-- This is how we access the contact values within our cContact container/wrapper -->
           <apex:column value="{!c.con.Name}" />
           <apex:column value="{!c.con.Email}" />
           <apex:column value="{!c.con.Phone}" />
      </apex:pageBlockTable>
    </apex:pageBlock>
  </apex:form>

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

public class wrapperClassController {

    
        //Our collection of the class/wrapper objects cContact
        public List<cContact> contactList {get; set;}
    
        //This method uses a simple SOQL query to return a List of Contacts
        public List<cContact> getContacts() {
            if(contactList == null) {
                contactList = new List<cContact>();
                for(Contact c: [select Id, Name, Email, Phone from Contact limit 10]) {
                    // As each contact is processed we create a new cContact object and add it to the contactList
                    contactList.add(new cContact(c));
                }
            }
            return contactList;
        }
         
        public PageReference sendsurvey() {    
                    //We create a new list of Contacts that we be populated only with Contacts if they are selected
            List<Contact> selectedContacts = new List<Contact>();


            //We will cycle through our list of cContacts and will check to see if the selected property is set to true, if it is we add the Contact to the selectedContacts list

            for(cContact cCon: getContacts()) {

                if(cCon.selected == true) {
                    selectedContacts.add(cCon.con);
                }
            }
    
            // Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc
            System.debug('These are the selected Contacts...');
            for(Contact con: selectedContacts) {
                system.debug(con);
            }
            contactList=null; // we need this line if we performed a write operation  because getContacts gets a fresh list now
            return null;
        }
    
    
        // This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value
        public class cContact {
            public Contact con {get; set;}
            public Boolean selected {get; set;}
    
            //This is the contructor method. When we create a new cContact object we pass a Contact that is set to the con property. We also set the selected value to false
            public cContact(Contact c) {
                con = c;
                selected = false;
            }
        }
    }
  • September 22, 2018
  • Like
  • 0
public class Tpactivities {
  public list<contact> cons{set;get;}
  
    public Tpactivities (){
     cons = [select id, firstname, lastname from contact];
    }

    public PageReference getfeedback() {
     cons = [select id, firstname, lastname from contact];
        return null;
    }

}
  • September 18, 2018
  • Like
  • 0
I have the below VF Page with 10 custom buttons,
<apex:page id="TeacherKPI_VF" controller="TeacherKPI_VF_Controller">
  <apex:form >
  <div style="text-align:center;">
      <h1 style="text-decoration: underline;">TEACHER'S KPI</h1><br/><br/>
      <apex:commandButton value="Lesson Observation" action="{!LessonObservation_VF}"/><br/><br/>
      <apex:commandButton value="File Check" action="{!FileCheck_VF}"/><br/><br/>
      <apex:commandButton value="Request for Corrective Action" action="{!RequestforCorrectiveAction_VF}"/><br/><br/>
      <apex:commandButton value="Withdrawal Trend" action="{!WithdrawalTrend_VF}"/><br/><br/>              
      <apex:commandButton value="Cost Recoverability Index" action="{!CostRecoverabilityIndex_VF}"/><br/><br/>
      <apex:commandButton value="Teacher Parent Dialogue Log" action="{!TeacherParentDialogueLog_VF}"/><br/><br/>
      <apex:commandButton value="Training sessions" action="{!TrainingSessions_VF}"/><br/><br/>
      <apex:commandButton value="Parent's Survey" action="{!ParentSurvey_VF}"/><br/><br/>
      <apex:commandButton value="Student's Survey" action="{!StudentSurvey_VF}"/><br/><br/>
      <apex:commandButton value="Leave / MC" action="{!LeaveMC_VF}"/><br/><br/>
      <apex:commandButton value="Back" action="{!Back}"/>      
  </div>
  </apex:form>
</apex:page>

When any of the button is click, need to open another VF PAGEs for example
<apex:commandButton value="Lesson Observation" action="{!LessonObservation_VF}"/><br/><br/> need to open VF Page LessonObservation_VF, I am not sure on how to do this, please help

The Class is not complete yet
public with sharing class TeacherKPI_VF_Controller {

    public PageReference Back() {
        return null;
    }

    public PageReference LeaveMC_VF() {
        return null;
    }

    public PageReference StudentSurvey_VF() {
        return null;
    }

    public PageReference ParentSurvey_VF() {
        return null;
    }

    public PageReference TrainingSessions_VF() {
        return null;
    }

    public PageReference TeacherParentDialogueLog_VF() {
        return null;
    }


    public PageReference CostRecoverabilityIndex_VF() {
        return null;
    }

    public PageReference WithdrawalTrend_VF() {
        return null;
    }

    public PageReference RequestforCorrectiveAction_VF() {
        return null;
    }

    public PageReference FileCheck_VF() {
        return null;
    }

    public PageReference LessonObservation_VF() {
        return null;
    }

}

 
  • July 19, 2017
  • Like
  • 0
Hello,
I created table in my custom object.But now I want to add new row to add more records.Though I created it with 'AddRow' button.
But when I click on that button it's showing no change. Please help with this.
Here I am posting my code:
<apex:page standardController="Student__c" extensions="addFunction">
<apex:form >
   
   <apex:sectionHeader title="Student Edit" subtitle="New Student"/>
  <apex:pageBlock mode="edit" >
  <apex:pageBlockButtons >
  <apex:commandButton action="{!Save}" value="Save"/>
  <apex:commandButton action="{!Cancel}" value="Cancel"/>
  </apex:pageBlockButtons>
   <apex:pageBlockSection title="Student Details" columns="1" >
   
     
     <apex:inputField value="{!Student__c.Student_Id__c}"/>
     <apex:inputField value="{!Student__c.Name}"/>
     <apex:inputField value="{!Student__c.Last_Name__c}"/>
     <apex:inputField value="{!Student__c.Contact_Number__c}" />
     <apex:inputField value="{!Student__c.Email_Id__c}"/>
     <apex:inputField value="{!Student__c.Address__c}"/>
     <apex:inputField value="{!Student__c.Degree__c}"/>
     <apex:inputField value="{!Student__c.Department__c}"/>
     
  </apex:pageBlockSection>
  

   <apex:pageBlockSection title="Course Details" id="hp">
   <apex:pageMessages />
 <apex:variable var="rowNumber" value="{!0}"/>
 
 
   
   
   <apex:pageBlockTable value="{!Student__c}" var="stu">
   <apex:column headerValue="No." style="width:20px; text-align:center;" headerClass="centertext">
 <apex:outputText value="{0}" style="text-align:center;"> 
 <apex:param value="{!rowNumber+1}" /> 
 </apex:outputText>
 </apex:column> 
 
      
      <apex:column headerValue="Courses"  >
      <apex:inputField value="{!stu.Courses__c}" />
      </apex:column>
      <apex:column headerValue="Professor" >
      <apex:inputField value="{!stu.Professor__c}"/>
      </apex:column>
      <apex:column headerValue="Final Grade" >
      <apex:inputField value="{!stu.Final_Grade__c}" />
      </apex:column>
      <apex:column headerValue="Action" >
 <apex:commandButton value="Delete" action="{!deleteRow}" reRender="hp">
 <apex:param name="rowIndex" value="{!rowNumber}"/>
 </apex:commandButton>
 <apex:variable var="rowNumber" value="{!rowNumber+1}"/>
 </apex:column> 
 
      
    
   
      
      
</apex:pageBlockTable>

<apex:commandButton action="{!addRow}" value="Add Course" reRender="hp"/>

 

</apex:pageBlockSection>


    </apex:pageBlock>
   </apex:form>
</apex:page>
Controller Code:
public class addFunction {

    
     public Student__c s;
 public Student__c del;
 public List<Student__c> addcourseList {get;set;}
 public List<Student__c> delcourseList {get;set;}
 public List<Student__c> courseList {get;set;}
 public Integer totalCount {get;set;}
 public Integer rowIndex {get;set;}
 
 public List<Student__c> delCourse {get; set;} 
 public addFunction(ApexPages.StandardController controller) {

    
 
 s = (Student__c)controller.getRecord();
 courseList = [Select Courses__c ,Professor__c,Final_Grade__c from Student__c  ];
 totalCount = courseList.size();
 
 delcourseList = new List<Student__c>();
 delCourse = new List<Student__c>();
 }
 
 public void addRow(){
 addcourseList = new List<Student__c>();
 courseList.add(new Student__c ());
 }
 
 public PageReference Save(){
 
 upsert courseList;
 delete delcourseList;
 return (new ApexPages.StandardController(s)).view();
 } 
 public void deleteRow(){
 
 rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
 System.debug('rowbe deleted ' + rowIndex );
 System.debug('rowm to be deleted '+courseList[rowIndex]);
 del = courseList.remove(rowIndex);
 delcourseList.add(del);
 }
 }
Error:
Visualforce Error
Help for this Page
System.DmlException: Upsert failed. First exception on row 0 with id a033600000RQRQjAAP; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Courses]: [Courses]
Error is in expression '{!Save}' in component <apex:commandButton> in page student_details_1: Class.addFunction.Save: line 32, column 1
Class.addFunction.Save: line 32, column 1