• Lakshmi Gupta 4
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
Hi,

I have created a custom object Attendance__c with three fields called contact__c, manager__c, manager's manager__c. They are all lookup relationship with contact object. I want to get these three names in my apex code. I'm able to get the contact__c with the below:
Select contact__r.name from attendace__c.  How can I get the names of manger and manager's manager which is lookup relation to contact object? Thanks for your help!!

User-added image
 
Hi All,

I'm trying to do Pagination in my VFpage.  I have the below code. When I preview the page all my buttons are Disabled. Can someone tell me why is it dispabled? Attendance__C had When I load the page it displays 10 records. 

Thanks for your help!!

public class PaginationAttendance{ 
 public String acctlist { get; set; }

    private integer totalRecs = 0;
    private integer OffsetSize = 0;
    private integer LimitSize= 10;
    
    public integer Pagination() {
        totalRecs = [select count() from attendance__c];
        return totalRecs;
    }
    
    public List<attendance__c> getacclist() {
        List<attendance__c> acc =[SELECT contact__c, Manager__c, Manager_s_Manager__c,
               Approved__c,Attendance_Date__c, Hours__C,
              Is_Eligible_for_compensatory_off__c, AttendanceType__c FROM Attendance__c LIMIT :LimitSize OFFSET :OffsetSize];
    return acc;
    }
    
    public void FirstPage() {
        OffsetSize = 0;
    }
    
    public void previous(){
        OffsetSize = OffsetSize - LimitSize;
    }
    
    public void next(){
        OffsetSize = OffsetSize + LimitSize;
    }
    
    public void LastPage()  {
        OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
    }
    
    public boolean getprev() {
        if(OffsetSize == 0)
        return true;
        else
        return false;
    }
    public boolean getnxt(){
        if((OffsetSize + LimitSize) > totalRecs)
        return true;
        else
        return false;
    }
}
===============================================================================

<apex:page controller="PaginationAttendance" sidebar="false" showHeader="false">
<apex:form > 
<apex:pageBlock id="details">
<apex:pageblockTable value="{!acclist}" var="acc">    
<apex:column value="{!acc.Contact__c}"/>
<apex:column value="{!acc.Manager__c}"/>
            <apex:column value="{!acc.Manager_s_Manager__c}"/>
            <apex:column value="{!acc.Approved__c}"/>
            <apex:column value="{!acc.Attendance_Date__c}"/>
            <apex:column value="{!acc.Hours__c}"/>            
            <apex:column value="{!acc.Is_Eligible_for_compensatory_off__c}"/>
            <apex:column value="{!acc.AttendanceType__c}"/>
</apex:pageblockTable>
<apex:pageblockButtons >
<apex:commandButton value="First Page" rerender="details" action="{!FirstPage}" disabled="{!prev}"/>
<apex:commandButton value="Previous" rerender="details" action="{!previous}" disabled="{!prev}"/>
<apex:commandButton value="Next" rerender="details" action="{!next}" disabled="{!nxt}"/>
<apex:commandButton value="Last Page" rerender="details" action="{!LastPage}" disabled="{!nxt}"/>
</apex:pageblockButtons>
</apex:pageBlock>
</apex:form></apex:page>
I'm new to Salesforce and trying to understand Get, Set method.  I have written this simple code, where user can search for a record from custom object Attendance. Set method is not assigning the value to variable "Keyword".  Can someone explain what is the problem with my code?

Thank you

public class simplegetset
{  

    string keyword;
    list <attendance__c> att;
    
    public string getkeyword(){
    return keyword;
    }

    public list <attendance__C> getatt(){
     return att;
    }   
    
    Public void setKeyword(string s){
      keyword = s;
      }
      
     Public pagereference ShowResults(){
     att = [select contact__c, Manager__c, Manager_s_Manager__c,
               Approved__c,Attendance_Date__c, Hours__C,
              Is_Eligible_for_compensatory_off__c, AttendanceType__c FROM Attendance__c where contact__C = :keyword];
     return null;
     }
     
}
============================================================================

<apex:page controller="simplegetset">
  <apex:form >
   <apex:pageblock title="List of Employee Attendance">
   <apex:inputtext value="{!Keyword}"/>
   
   <apex:commandButton value="Show Results" action="{!ShowResults}" rerender="details"/>  
    <apex:pageblockTable value="{!att}" Var="a" id="details">
    <apex:column value="{!a.Contact__c}"/>
    <apex:column value="{!a.Manager__c}"/>
    <apex:column value="{!a.Manager_s_Manager__c}"/>
    <apex:column value="{!a.Approved__c}"/>  
    <apex:column value="{!a.Attendance_Date__c}"/>
    <apex:column value="{!a.Hours__c}"/>
    <apex:column value="{!a.AttendanceType__c }"/>    
   </apex:Pageblocktable>
   
   <apex:outputtext >{!keyword}
   </apex:outputtext> 
    </apex:pageblock>                
  </apex:form>    
</apex:page>

 
Hello,

How can I write a workflow to update Account rating to warm, When a case origin is email?

Thank you!
Hi All,

I'm trying to do Pagination in my VFpage.  I have the below code. When I preview the page all my buttons are Disabled. Can someone tell me why is it dispabled? Attendance__C had When I load the page it displays 10 records. 

Thanks for your help!!

public class PaginationAttendance{ 
 public String acctlist { get; set; }

    private integer totalRecs = 0;
    private integer OffsetSize = 0;
    private integer LimitSize= 10;
    
    public integer Pagination() {
        totalRecs = [select count() from attendance__c];
        return totalRecs;
    }
    
    public List<attendance__c> getacclist() {
        List<attendance__c> acc =[SELECT contact__c, Manager__c, Manager_s_Manager__c,
               Approved__c,Attendance_Date__c, Hours__C,
              Is_Eligible_for_compensatory_off__c, AttendanceType__c FROM Attendance__c LIMIT :LimitSize OFFSET :OffsetSize];
    return acc;
    }
    
    public void FirstPage() {
        OffsetSize = 0;
    }
    
    public void previous(){
        OffsetSize = OffsetSize - LimitSize;
    }
    
    public void next(){
        OffsetSize = OffsetSize + LimitSize;
    }
    
    public void LastPage()  {
        OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
    }
    
    public boolean getprev() {
        if(OffsetSize == 0)
        return true;
        else
        return false;
    }
    public boolean getnxt(){
        if((OffsetSize + LimitSize) > totalRecs)
        return true;
        else
        return false;
    }
}
===============================================================================

<apex:page controller="PaginationAttendance" sidebar="false" showHeader="false">
<apex:form > 
<apex:pageBlock id="details">
<apex:pageblockTable value="{!acclist}" var="acc">    
<apex:column value="{!acc.Contact__c}"/>
<apex:column value="{!acc.Manager__c}"/>
            <apex:column value="{!acc.Manager_s_Manager__c}"/>
            <apex:column value="{!acc.Approved__c}"/>
            <apex:column value="{!acc.Attendance_Date__c}"/>
            <apex:column value="{!acc.Hours__c}"/>            
            <apex:column value="{!acc.Is_Eligible_for_compensatory_off__c}"/>
            <apex:column value="{!acc.AttendanceType__c}"/>
</apex:pageblockTable>
<apex:pageblockButtons >
<apex:commandButton value="First Page" rerender="details" action="{!FirstPage}" disabled="{!prev}"/>
<apex:commandButton value="Previous" rerender="details" action="{!previous}" disabled="{!prev}"/>
<apex:commandButton value="Next" rerender="details" action="{!next}" disabled="{!nxt}"/>
<apex:commandButton value="Last Page" rerender="details" action="{!LastPage}" disabled="{!nxt}"/>
</apex:pageblockButtons>
</apex:pageBlock>
</apex:form></apex:page>
I'm new to Salesforce and trying to understand Get, Set method.  I have written this simple code, where user can search for a record from custom object Attendance. Set method is not assigning the value to variable "Keyword".  Can someone explain what is the problem with my code?

Thank you

public class simplegetset
{  

    string keyword;
    list <attendance__c> att;
    
    public string getkeyword(){
    return keyword;
    }

    public list <attendance__C> getatt(){
     return att;
    }   
    
    Public void setKeyword(string s){
      keyword = s;
      }
      
     Public pagereference ShowResults(){
     att = [select contact__c, Manager__c, Manager_s_Manager__c,
               Approved__c,Attendance_Date__c, Hours__C,
              Is_Eligible_for_compensatory_off__c, AttendanceType__c FROM Attendance__c where contact__C = :keyword];
     return null;
     }
     
}
============================================================================

<apex:page controller="simplegetset">
  <apex:form >
   <apex:pageblock title="List of Employee Attendance">
   <apex:inputtext value="{!Keyword}"/>
   
   <apex:commandButton value="Show Results" action="{!ShowResults}" rerender="details"/>  
    <apex:pageblockTable value="{!att}" Var="a" id="details">
    <apex:column value="{!a.Contact__c}"/>
    <apex:column value="{!a.Manager__c}"/>
    <apex:column value="{!a.Manager_s_Manager__c}"/>
    <apex:column value="{!a.Approved__c}"/>  
    <apex:column value="{!a.Attendance_Date__c}"/>
    <apex:column value="{!a.Hours__c}"/>
    <apex:column value="{!a.AttendanceType__c }"/>    
   </apex:Pageblocktable>
   
   <apex:outputtext >{!keyword}
   </apex:outputtext> 
    </apex:pageblock>                
  </apex:form>    
</apex:page>