Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I'm trying to reproduce the "Created By" and "Modified By" fields in one of my Visualforce pages, and I'm almost there.

    <tr>
      <td>Created By</td>
      <td>
        <apex:outputLink value="/{!Custom_Object__c.CreatedBy.Id}">
            {!Custom_Object__c.CreatedBy.Name}
        </apex:outputLink>
        <apex:outputText value=", {!Custom_Object__c.CreatedDate}"/>
      </td>
    </tr>

I need to replace the text Created By with a dynamic label localized for the current user. I've tried {!$ObjectType.Custom_Object__c.Fields.CreatedBy.Label}, but I get an Unknown property error when I try to save. I can't use Fields.CreatedByID.Label since that's actually the text Created By ID.

Do I need to do something with getChildRelationships()? Look it up in my Apex code and expose it to Visualforce?

Or is this a case where I'm not going to find a label that contains a localized version of Created By and I have to choose between Created By ID, Created Date, or creating my own label and translations?

share|improve this question
2  
I recently ran into a similar issue when trying to get the label of salesforce's standard Created By, Last Modified By, etc, fields. I produced the same results as you, in that the label returned was actually "Created By Id", etc. Apparently Salesforce knows about this and it's "working as expected". So in this case, I would probably opt for creating your own label and translations. –  jonnybro Feb 27 '13 at 1:43
    
It's been a long time since I've dealt with translations, but I recall having the same issue jonnybro mentions. Probably going to have to use custom labels. –  jkraybill Feb 27 '13 at 2:03
    
@jonnybro arrgh!! "working as expected" what a cop out. –  Ralph Feb 27 '13 at 17:45
    
The same question is without answer since long time ago in stackoverflow.com/questions/12860127/…, so I think that $Label.CreatedBy gonna be a proper workaround –  Martin Borthiry Apr 10 '13 at 3:00
add comment

2 Answers 2

up vote 0 down vote accepted

I've had a look around at this, i agree it does seem frustrating you cannot reuse this label and the translations that Salesforce have provided. I think the problem stems from the fact that all the Visualforce and Apex options available utilise the Apex Describe behaviour, which is bound to the underlying schema of your object, as can be seen by this from Eclipse, there is not such field, so I assume its UI thing.

enter image description here

On this basis, I'm pretty sure your only real solution is to use Custom Labels as has been mentioned in the comments, accessed via $Label described here. If your unsure of the translations to put into the Custom Label, I guess you can switch your user into each language and copy paste!

$Label.CreatedBy
share|improve this answer
add comment

Did you try to expose to VF schema label from an apex controller? Something like

String createdByLabel = CustomObject.CreatedById.getDescribe().getLabel();
share|improve this answer
    
That's the Apex way of referencing what I've already used, and will return Created by ID. –  tomlogic Mar 16 '13 at 6:34
add comment

Your Answer

 
discard

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.