+ Start a Discussion
Vijay sidaraddiVijay sidaraddi 

not able to save apex class

HI friends,

Suggest me wherer im wrong in this apex class


public with sharing class Pdfcontroller {
   { public List assList{get;set;}
    public Pdfcontroller (){
        assList = [select assignmentnumber,AFE,inspectionlevel,ProjectName,status from assignmentpackage limit 10];
    }
}

***************Vf page*******************
<apex:page controller="PdfController" renderAs="pdf">
  <apex:form >
    <apex:pageBlock >
        <apex:pageBlockTable value="{!assList}" var="ass" border="2">
           <apex:column value="{!ass.assignmentnumber}"/>
           <apex:column value="{!ass.AFE}"/>
           <apex:column value="{!ass.inspectionlevel}"/>
           <apex:column value="{!ass.ProjectName}"/>
           <apex:column value="{!ass.status}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
  </apex:form>
</apex:page>

 
Best Answer chosen by Vijay sidaraddi
NagendraNagendra (Salesforce Developers) 
Hi Vijay,

Assuming as you are referring to a custom object and custom fields please update your code as below 

Controller:
public with sharing class Pdfcontroller  { 
   public List<assignmentpackage__c> assList {get;set;}
    public  Pdfcontroller (){
        assList = [select assignmentnumber__c,AFE__c,inspectionlevel__c,ProjectName__c,status__c from assignmentpackage__c limit 10];
    }
}

VF Page;
<apex:page controller="PdfController" renderAs="pdf">
  <apex:form >
    <apex:pageBlock >
        <apex:pageBlockTable value="{!assList}" var="ass" border="2">
           <apex:column value="{!ass.assignmentnumber__c}"/>
           <apex:column value="{!ass.AFE__c}"/>
           <apex:column value="{!ass.inspectionlevel__c}"/>
           <apex:column value="{!ass.ProjectName__c}"/>
           <apex:column value="{!ass.status__C}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
  </apex:form>
</apex:page>

Please mark this as best answer if the information helps.

Best Regards,
Nagendra.P

All Answers

karthikeyan perumalkarthikeyan perumal
Hello 

Use updated class 
 
public with sharing class Pdfcontroller  
   { 
   public List<assignmentpackage> assList {get;set;}
    public  Pdfcontroller (){
        assList = [select assignmentnumber,AFE,inspectionlevel,ProjectName,status from assignmentpackage limit 10];
    }
}
Also check your object API name and field Api Names. 

Hope this will help you.. 

Mark Best ANSWER if its work for you. 

Thanks
karthik
 
NagendraNagendra (Salesforce Developers) 
Hi Vijay,

Assuming as you are referring to a custom object and custom fields please update your code as below 

Controller:
public with sharing class Pdfcontroller  { 
   public List<assignmentpackage__c> assList {get;set;}
    public  Pdfcontroller (){
        assList = [select assignmentnumber__c,AFE__c,inspectionlevel__c,ProjectName__c,status__c from assignmentpackage__c limit 10];
    }
}

VF Page;
<apex:page controller="PdfController" renderAs="pdf">
  <apex:form >
    <apex:pageBlock >
        <apex:pageBlockTable value="{!assList}" var="ass" border="2">
           <apex:column value="{!ass.assignmentnumber__c}"/>
           <apex:column value="{!ass.AFE__c}"/>
           <apex:column value="{!ass.inspectionlevel__c}"/>
           <apex:column value="{!ass.ProjectName__c}"/>
           <apex:column value="{!ass.status__C}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
  </apex:form>
</apex:page>

Please mark this as best answer if the information helps.

Best Regards,
Nagendra.P
This was selected as the best answer
Vijay sidaraddiVijay sidaraddi
thanks lot nagendra, its working fine as expected..