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
Sorcerer7Sorcerer7 

How do I pull a formula field into a Blocktable?

I am building a Visualforce page that lists the Training videos we offer. I an using a custom object for the training videos and in the table on the VF page, I need to list the "Course Code" for the video. The Corse Code field is a formual field. I am getting this error when I save..
"Error: Formula expression is required for attribute value in <apex:column> in Sales_Certification_Courses at line 10 column 59"
Here is the code so far...
<apex:page standardController="Guidance_University__c" recordSetVar="Guidance_University__c" sidebar="false">
     <h1> Welcome to the Guidance University Sales Certification Courses </h1>
        <apex:pageBlock >
                    <apex:pageBlock title="Guidance University Sales Certification Training Videos">
                         <apex:pageBlockTable value="{!Guidance_University__c}" var="a">
                              <apex:column value="{!a.name}"/>
                              <apex:column value="{Course_Code_v2__c}"/>
                              <apex:column value="{Course_Level__c}"/>
                              <apex:column value="{Topic_Subject__c}"/>
                               <apex:column value="{video_Link__c}"/>
                 </apex:pageBlockTable>
      </apex:pageBlock/>
</apex:page>
Best Answer chosen by Sorcerer7
Abhishek BansalAbhishek Bansal
Hi,

I have modified your code.
Please update your code as below :
 
<apex:page standardController="Guidance_University__c" recordSetVar="Guidance_University__c" sidebar="false">
	<h1> Welcome to the Guidance University Sales Certification Courses </h1>
	<apex:pageBlock title="Guidance University Sales Certification Training Videos">
    	<apex:pageBlockTable value="{!Guidance_University__c}" var="a">
        	<apex:column value="{!a.name}"/>
            <apex:column value="{!a.Course_Code_v2__c}"/>
            <apex:column value="{!a.Course_Level__c}"/>
            <apex:column value="{!a.Topic_Subject__c}"/>
            <apex:column value="{!a.video_Link__c}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

Hope everything is fine now :)

Thanks,
Abhishek

All Answers

Abhishek BansalAbhishek Bansal
Hi,

There is a syntax error in your code which has been corrected by me.
Please find the modified code below :
 
<apex:page standardController="Guidance_University__c" recordSetVar="Guidance_University__c" sidebar="false">
     <h1> Welcome to the Guidance University Sales Certification Courses </h1>
        <apex:pageBlock >
                    <apex:pageBlock title="Guidance University Sales Certification Training Videos">
                         <apex:pageBlockTable value="{!Guidance_University__c}" var="a">
                              <apex:column value="{!a.name}"/>
                              <apex:column value="{!Course_Code_v2__c}"/>
                              <apex:column value="{!Course_Level__c}"/>
                              <apex:column value="{!Topic_Subject__c}"/>
                               <apex:column value="{!video_Link__c}"/>
                 </apex:pageBlockTable>
      </apex:pageBlock/>
</apex:page>

You were missing "!" in colum values.
Hope this helps.

Thanks,
Abhishek
Sorcerer7Sorcerer7
Hi Abhishek,
Thank you so much, I can't believe I missed that.
I also had one too many "apex:pageBlock"'s in there.
Now I am getting this error..
Error: Sales_Certification_Courses line 21, column 16: The end-tag for element type "a" must end with a '>' delimiter
Error: The end-tag for element type "a" must end with a '>' delimiter.
Here is the code now...
<apex:page standardController="Guidance_University__c" recordSetVar="Guidance_University__c" sidebar="false">

         <h1> Welcome to the Guidance University Sales Certification Courses </h1>

            <apex:pageBlock ="Guidance University Sales Certification Training Videos">

                             <apex:pageBlockTable value="{!Guidance_University__c}" var="a">

                                  <apex:column value="{!a.name}"/>

                                  <apex:column value="{!Course_Code_v2__c}"/>

                                  <apex:column value="{!Course_Level__c}"/>

                                  <apex:column value="{!Topic_Subject__c}"/>

                                   <apex:column value="{!video_Link__c}"/>
                       
                             </apex:pageBlockTable>

            </apex:pageBlock>

    </apex:page>

This stuff drives you nuts sometimes. :)
Abhishek BansalAbhishek Bansal
Hi,

Again there is a syntax mistake in your code.
Please change your code as below :
 
<apex:page standardController="Guidance_University__c" recordSetVar="Guidance_University__c" sidebar="false">
	<h1> Welcome to the Guidance University Sales Certification Courses </h1>
	<apex:pageBlock title="Guidance University Sales Certification Training Videos">
    	<apex:pageBlockTable value="{!Guidance_University__c}" var="a">
        	<apex:column value="{!a.name}"/>
            <apex:column value="{!Course_Code_v2__c}"/>
            <apex:column value="{!Course_Level__c}"/>
            <apex:column value="{!Topic_Subject__c}"/>
            <apex:column value="{!video_Link__c}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

You were missing title in PageBlock.

Thanks,
Abhishek
Sorcerer7Sorcerer7
But that's not what the error said was wrong? I will make the change per your solution though.
 
Sorcerer7Sorcerer7
OK, so now I get this error...
Error: Unknown property 'Guidance_University__cStandardController.Course_Code_v2__c'
Is that becasue that field is a "formula field"?
Abhishek BansalAbhishek Bansal
Hi,

I have modified your code.
Please update your code as below :
 
<apex:page standardController="Guidance_University__c" recordSetVar="Guidance_University__c" sidebar="false">
	<h1> Welcome to the Guidance University Sales Certification Courses </h1>
	<apex:pageBlock title="Guidance University Sales Certification Training Videos">
    	<apex:pageBlockTable value="{!Guidance_University__c}" var="a">
        	<apex:column value="{!a.name}"/>
            <apex:column value="{!a.Course_Code_v2__c}"/>
            <apex:column value="{!a.Course_Level__c}"/>
            <apex:column value="{!a.Topic_Subject__c}"/>
            <apex:column value="{!a.video_Link__c}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

Hope everything is fine now :)

Thanks,
Abhishek
This was selected as the best answer
Sorcerer7Sorcerer7
Worked like a charm. Thanks Abhishek !
Sorcerer7Sorcerer7
Hey Abhishek,
Have a new question for you. I would like to put a "filter" into the code, so that a user can select training videos that are in a certian category. I can't find the section in the on line developers guide.
Can you help with this?
Thanks