2

If I display an inputField on a Visualforce field for the WhatId field on an Event object (like so: <apex:inputField value="{!Event.WhatId}" />), then the label of the input will be Related To. This is because the Field Label for this field is set to Related To.

However, if I try to display the field label like so: <apex:outputLabel>{!$ObjectType.Event.fields.WhatId.Label}</apex:outputLabel>, then the label will display as Related To ID (as opposed to Related To).

How can I use the apex:outputLabel tag to render the correct label for the WhatId field?

The same problem happens with the WhoId field, and so I am hoping that there is a reasonable solution to this problem.

1
  • can you please post your visualforce here – Santanu Boral Jan 30 '17 at 17:53
0

To display the correct Label instead of What Id which is generic one. use this

WhatId Object is: <apex:outputLabel>{!Event.What.Type}</apex:outputLabel>

It will display like this:

What Id Object

Similarly, to find Object name of WhoId use this:

WhoId Object is: <apex:outputLabel>{!Event.Who.Type}</apex:outputLabel>

Who Id

Update

According to your question you want to display "Related To" label instead of "Related To Id". There are no such direct ways we can display like that. Please find the Event field APIs in workbench.

Only option could be just trim off "Id" portion from the displayed label.

<apex:outputLabel>
{!LEFT($ObjectType.Event.fields.WhatId.Label, LEN($ObjectType.Event.fields.WhatId.Label)-2)}
</apex:outputLabel>

WhatId desc

7
  • I'm not sure this answers the question. – Chris Payne Jan 30 '17 at 18:33
  • please find my updated ans – Santanu Boral Jan 30 '17 at 20:54
  • 1
    This gives me the type of the object that is selected in the field, as opposed to the label for the field. – Chris Payne Jan 30 '17 at 22:34
  • Do you like to display "Related To" rather than "Related To Id"? – Santanu Boral Jan 30 '17 at 22:43
  • Please find updated ans – Santanu Boral Jan 30 '17 at 23:22

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.