4

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. https://www.salesforce.com/us/developer/docs/pages/Content/pages_dynamic_vf_globals_objecttype.htm

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}"/>
</apex:component>

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.

5

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

Check the version setting for your component.

2
  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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