function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
b.gonzalezb.gonzalez 

APEX CLASS - Compile Error: unexpected token: 'Program' at line 2 column 14

This is my first time writing a Apex Class. I have created a visual force page for a custom object. The purpose of the visualforce page is to be a PDF version of the custom object detail page.

 

When I try to save the Apex Class in my SANDBOX, I receive the following  Error: Compile Error: unexpected token: 'Program' at line 2 column 14

 

I interested the APEX CLASS code and VisualForce page code in this post.

 

I appreciate any help I can get in resolving this error. 

 

 Below is the APEX CLASS code:

 

public class ApprovedFundedProgramRequestPDF{
public Funded Program Request;
public DateTime craDateTime = DateTime.now();
private ApexPages.StandardController stdController;

public ApprovedFundedProgramRequestPDF(ApexPages.StandardController stdController){
    this.stdController = stdController;
    fpr = (Funded_Program_Request__c)stdController.getRecord();
}        

// Attach Approved Funded Program Request to current Funded_Program_Request__c

public PageReference attachApprovedFundedProgramRequestPDF(){
            
// Get the page definition 
PageReference pdfPage = Page.ApprovedFundedProgramRequestPDF;

// Generate the pdf blob
Blob pdfBlob = pdfPage.getContent();

// Create the attachment against the Approved Funded Program Request page 
Attachment a = new Attachment(parentId = opp.id, name=opp.name + ' - CRA ' + craDateTime.formatlong() + '.pdf', body = pdfBlob);
        
// Insert the attachment into the Funded Program Request
insert a;

// Send the user back to the events detail page
return stdController.view(); 
}

}

 Below is the VisualForce page code:

<apex:page > standardController="Funded_Program_Request_c" standardStylesheets = "false" showHeader="false" renderAS="pdf" 

extension="ApprovedFundedProgramRequestPDF">
    <body>
        <apex:stylesheet value="{!URLFOR($Resource.styles, 'styles.css')}"/>
         <center><apex:image value="{!URLFOR($Resource.QLogicLogos,'ultimate_logo_horiz_blue_on_white_small.jpg')}"/></center>
        <center><u>
            <apex:outputText value="{!$Organization.Street}" style="font-size:12px"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <apex:outputText value="{!$Organization.City}, {!$Organization.State} {!$Organization.PostalCode}" style="font-

size:12px"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <apex:outputText value="{!$Organization.Phone}" style="font-size:12px"/>  
        </u></center>   
        <br></br><br></br>
        <br></br><center><apex:outputText value="Approved Funded Program Request" style="font-weight:bold; font-size:30px" 

/></center><br></br>
        <b> Date: </b> <apex:outputText value=" {!NOW()}" /><br></br><br></br>
        <br></br><center><apex:outputText value="Program Summary" style="font-weight:bold; font-size:20px" /></center><br></br>
        <b> Funded Program Name: </b> <apex:outputText value="{!Funded_Program_Request_c.Name}" /><br></br><br></br>
        <b> Funded Request Status: </b> <apex:outputText value="{!Funded_Program_Request_c.Funded_Request_Status__c}" 

/><br></br><br></br>
        <b> Source of Funding: </b> <apex:outputText value="{!Funded_Program_Request_c.Source_Of_Funding__c}" /><br></br><br></br>
        <b> Other Source of Funding: </b> <apex:outputText value="{!Funded_Program_Request_c.Other_Source_of_Funding__c" 

/><br></br><br></br>
        <b> Theater: </b> <apex:outputText value="{!Funded_Program_Request_c.Theater__c}" /><br></br><br></br>
        <b> Goal Alignment: </b> <apex:outputText value="{!Funded_Program_Request_c.Goal_Alignment__c}" /><br></br><br></br>
        <b> Product Focus: </b> <apex:outputText value="{!Funded_Program_Request_c.Theater__c}" /><br></br><br></br>
        <b> Other Product: </b> <apex:outputText value="{!Funded_Program_Request_c.Other_Product__c" /><br></br><br></br>
        <br></br><br></br>
        <br></br><center><apex:outputText value="Payment Information" style="font-weight:bold; font-size:20px" 

/></center><br></br><br></br>
    	<b> Partner(Company Name): </b> <apex:outputText value="{!Funded_Program_Request.Partner__c}" />
        <br></br> <br></br><b>
        <apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_r.Street_Name__c}" />  
            <apex:outputText value="{!Funded_Program_Request_r.City__c}" />   
            <apex:outputText value="{!Funded_Program_Reques_r.PostalCode__c}" />
        </apex:panelGrid></b>
        <apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_r.Partner_Contact__c}" />  
            <apex:outputText value="{!Funded_Program_Reques_r.Contact_Email__c}" />   
            <apex:outputText value="{!Funded_Program_Request_r.Contact_Phone__c}" />
        </apex:panelGrid></b>
    	<apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_c.Method_of_Payment__c}" />  
            <apex:outputText value="{!Funded_Program_Reques_c.QLogic_Credit_Memo__c}" />   
            <apex:outputText value="{!Funded_Program_Request_C.QLogic_PO__c}" />
        </apex:panelGrid></b>
	<apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_c.Payment_Due_Date__c}" />  
            <apex:outputText value="{!Funded_Program_Reques_c.Company_Tax_ID__c}" />   
            <apex:outputText value="{!Funded_Program_Request_C.Quote_Provided__c}" />
        </apex:panelGrid></b>
        <br></br><br></br>
<br></br><center><apex:outputText value="Program Review" style="font-weight:bold; font-size:20px" /></center><br></br><br></br>
        <apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_c.Activity_Date__c}" />  
            <apex:outputText value="{!Funded_Program_Request_c.Event_Format__c}" />   
            <apex:outputText value="{!Funded_Program_Reques_c.Other_Format__c}" />
        </apex:panelGrid></b>
        <apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_c.Call_to_Action__c}" />  
            <apex:outputText value="{!Funded_Program_Reques_c.Budget_Line_Item__c}" />   
            <apex:outputText value="{!Funded_Program_Request_c.Existing_Budget_Line_Item__c}" />
        </apex:panelGrid></b>
  	<apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_c.Funding_Requested__c}" />  
            <apex:outputText value="{!Funded_Program_Reques_c.How_will_Performance_be_Measured__c}" />   
            <apex:outputText value="{!Funded_Program_Request_c.Estimated_Performance_Value__c}" />
        </apex:panelGrid></b>
        <br></br><br></br>
        <br></br><br></br>
    </body>
</apex:page>

 

 

Best Answer chosen by Admin (Salesforce Developers) 
JPClark3JPClark3

Yes, now you need to add a variable name. The variable name is then used in the program to access the field values. So, you can add something like this:

 

public Funded_Program_Request__c FundedProgReq;

This is called a variable declaration. 

Unfortunately, this is kinda some very basic programming skills you should get up to speed before diving into a large file as you've posted. I won't be able to help with each compile error.

 

All Answers

JPClark3JPClark3

What is "Funded Program Request"? Is the a custom object?

If it is, then you probably want line #2 to be something like:

public Funded_Program__c Request;

 

You need to use the API Name of the custom objects. You can find this on the page where you created or edited the Custom Object.

 

 

JPClark3JPClark3

Also, you should start with small apex code as you're learning. It is easier to debug by saving very often, so the compile errors will only be in the newly added code lines each time.

b.gonzalezb.gonzalez

Thanks! I did that and changed it to:  public Funded_Program_Request__c;  (which I copied from the custom object itself)

 

But know I am reciving the following Error: Compile Error: unexpected token: 'Funded_Program_Request__c' at line 2 column 7

JPClark3JPClark3

Yes, now you need to add a variable name. The variable name is then used in the program to access the field values. So, you can add something like this:

 

public Funded_Program_Request__c FundedProgReq;

This is called a variable declaration. 

Unfortunately, this is kinda some very basic programming skills you should get up to speed before diving into a large file as you've posted. I won't be able to help with each compile error.

 

This was selected as the best answer
b.gonzalezb.gonzalez

Thank you for the help! I appreciate it. 

 

`Beth