You need to sign in to do that
Don't have an account?
sfdcfox
$ObjectType[ObjectName]['Label']
I remember this working previously (or some incarnation thereof), but it's not working now when I'd actually like to use it. Does anyone know what the new method for displaying a dynamic sobject's label is without resorting to a describe call in a controller or extension?
There is definitely a bug here with a $objectType dynamic reference.
There is a weird possible workaround. It appears if you have a reference to fields that precedes it, then the label reference works ok.
e.g.
{!$ObjectType[objectname].fields.name}
You could maybe embed such a reference in a hidden field.
All Answers
{!$ObjectType.Account.Fields.Name.Label}
$ObjectType.Role_Limit__c.Fields.Limit__c.
Above is what you need?
I have a custom component that works across multiple objects, so I need to be able to display the object's label dynamically; the page won't know what it's displaying until runtime. I think I'm going to just waste a getDescribe() in my controller, as much as I hate to do this. I know it was working before, but it's failing to work now, and I don't really have time to research why.
The describe is the only option i think because i tried in my dev org and didnt got the label
Any news on this? I was trying to do something similar, but I couldn't get it to work. I posted about it here http://boards.developerforce.com/t5/Java-Development/Javascript-GETRECORDIDS-on-Contract-to-Return-Account-Ids/td-p/439347 .
There is definitely a bug here with a $objectType dynamic reference.
There is a weird possible workaround. It appears if you have a reference to fields that precedes it, then the label reference works ok.
e.g.
{!$ObjectType[objectname].fields.name}
You could maybe embed such a reference in a hidden field.
I am not quite sure that I follow. Are you talking something like this?
Or adding a test field that says $ObjectType[Contract].fields.AccounId and referencing that someone?
*EDIT* I can probably take out that "REQUIRESCRIPT" portion, right?
Thanks for the bug workaround; I just tested it and it works. I'll use this workaround now. It'll be nice when they get it fixed. Your workaround saves me an unnecessary describe call.
And yes, that script include is only if you plan on using the API, which you don't (at least, not in the snippet). It doesn't resolve my current problem though, but the other response did fix the problem admirably.
sfdcfox, would you be able to post a code snippet of it? I don't quite follow aballard's explanation.
It works something like this:
Basically, by accessing fields at least once, it corrects the object's describe. I believe it has to be "before" the attempt to use the label, but doesn't need to be rendered (but does need to be evaluated).
Oh, I see now. Is this exclusive to apex? I was trying to use this in a javascript button using the getrecordids function. The documentation on this function was pretty minimal so I wasn't aware it was intended for apex.
Thanks.
As far as I'm aware, $ObjectType has to use a discrete object when you're trying to use GETRECORDIDS (it basically substitutes the object key into the formula).
You use GETRECORDIDS as follows:
This places a JavaScript Array into the variable "records", with each numerical index location being a selected record ID.
Mhmm, that explanation seems to make sense. The issue I have is that the ObjectType field does not determine the actual record ids; rather the type of record selected in the list view determines that. So for example, I have a contract list set up, and my button is to output the "records" variable below. Instead of returning an Account Id, it returns the Contract Id instead. I need the Account Id in my situation...