Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I found myself using a bit of code to display a searchable history of a given SObject, for a couple of different SObjects so I thought it sensible to create a component, that could be told the SObject type as a parameter and work for any SObject.

When I got going on the component's VisualForce, I can't save. There's an error:

Syntax Error: found '$ObjectType'.

I think this is strange because the SFDC docs example of $ObjectType is building an apex:component.

So maybe I'm misinterpreting the error, or some issue elsewhere in the page is causing SFDC to say this. So I copy the whole thing over to an apex page, where it compiles perfectly. Perplexed, I cut my page right down, and discover that this doesn't save:

<apex:component >
    <apex:outputText value="{!$ObjectType['Account'].fields['Name'].Label}"/>

Still has the error: "Syntax Error: Found '$ObjectType'".

What gives? Why can't I use $ObjectType in a component? I can't find any reference to this anywhere.

share|improve this question
up vote 4 down vote accepted

From a quick check, this looks more likely to be an API version problem; I can save this in a component set to use API version 20.0 (or greater) but not in one set to use API version 19.0 (or less).

Check the version setting for your component.

share|improve this answer
Hi Keith. I just wrote it, so I'd expect it to be v30.0 like my eclipse. But I can't see a "version" flag in the -meta.xml. How do I find / define the version? – Dominic Aug 3 '14 at 18:18
They were set to API version 15, so I used SFDC UI to change them to 30.0 but they still won't save. I wondered if something in eclipse is trying to force them to be 15.0, so I've saved the component directly into the SFDC UI and it saves fine. I guess that a) the API version was the problem b) I need to ask a new question about why my eclipse is saving the component as v15.0 – Dominic Aug 3 '14 at 18:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.