0

I am trying to generate the pdf of the records that are visible based on the two filter that are the user name and the Category by choosing these two options I am filtering the records and now I want that only the viewed record should get inserted into pdf format when I click the generate pdf button so what should I suppose to do?

Apex code to search the records based on the filters :-

Trailhead Record Tracking



User Name :-
Category :-

        <apex:pageBlock rendered="true" title="Search Result">
        <apex:pageBlockTable value="{!lstAccount}" var="acc">
                            <apex:column >
                <apex:facet name="header">BatchName</apex:facet> 
                <apex:outputLink value="/{!acc.id}">{!acc.Batch_Name__c}</apex:outputLink>
            </apex:column>

             <apex:column >
                <apex:facet name="header">Name</apex:facet> 
                <apex:outputField value="{!acc.Name__c}"/>
            </apex:column> 

            <apex:column >
                <apex:facet name="header">TrailheadScores</apex:facet> 
                <apex:outputField value="{!acc.Trailhead_Scores__c}"/>
            </apex:column> 



            <apex:column >
                <apex:facet name="header">Number of Badges</apex:facet> 
                <apex:outputField value="{!acc.Number_of_Badges__c}"/>
            </apex:column> 

               <apex:column >
                <apex:facet name="header">Email</apex:facet> 
                <apex:outputField value="{!acc.Email__c}"/>
            </apex:column>

                <apex:column >
                <apex:facet name="header">Status</apex:facet> 
                <apex:outputField value="{!acc.Status__c}"/>
            </apex:column>

             <apex:column >
                <apex:facet name="header">Category</apex:facet> 
                <apex:outputField value="{!acc.Category__c}"/>
            </apex:column>

        </apex:pageBlockTable>  
                 <apex:pageBlockSection rendered="{!showSection1}">


            <apex:outputLabel value="No Result Found"></apex:outputLabel>
        </apex:pageblockSection>
 </apex:pageBlock>



 </apex:form>


  <script>

      var id2 = '{!$Component.form1.inp2}';
      document.getElementById(id2).style.display='none';           // It hides the input text field
      var btn1 = '{!$Component.form1.btn1}';

      var id4 = '{!$Component.form1.inp4}';
      document.getElementById(id4).style.display='none';


      function copy(){                                            // this function will execute when the search button is clicked


          var id = '{!$Component.form1.inp1}';                    
          var id3 = '{!$Component.form1.inp3}';           // Finding the inputField element and retrieving the string written in it

          var input1 = document.getElementById(id).value;           // Finding the inputField element and retrieving the string written in it
          document.getElementById(id2).value=input1;

          var input2 =document.getElementById(id3).value;           // Finding the inputField element and retrieving the string written in it
          document.getElementById(id4).value=input2;


                       // Inserting the retrieved string in the inputText field(hidden)
      }
  </script>

Controller code:-

public class ctrlSearch {

public ctrlSearch(ApexPages.StandardSetController controller) {

}

public Boolean showSection1{get;set;}
 public ctrlSearch(ApexPages.StandardController controller) {
 showSection1= false;
}
 public List<Daily_Record__c> lstAccount {get; set;}
 public string strAccSearchString {get;set;} 
 public string strAccSearchString1 {get;set;}   
 public boolean isResultDisplay {get; set;}
 public ctrlSearch(){
  lstAccount = new List<Daily_Record__c>();
    isResultDisplay = false;
}
public void SearchAccountRec(){
showSection1= true;
    isResultDisplay = true;
    string strLikeString = '%'+strAccSearchString+'%';
    string strLikeString1 = '%'+strAccSearchString1+'%';
   String strSOQL = 'select Batch_Name__c,Name__c, Trailhead_Scores__c 
    ,Number_of_Badges__c, Email__c,Status__c,Category__c  from 
      Daily_Record__c  where Username__r.Name like :strLikeString and 
        Category__c like :strLikeString1'; 
   lstAccount = database.query(strSOQL);

}

}

so please guide me how do I achieve the above requirements..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.