0

I'd like to build a field similar to the standard Owner field, which includes a [Change] link immediately to the right of the field value.

However, the additional requirement I have is that the link open in a new window.

Things I've tried:

1.<apex:outputlink>

Allows opening in new window, but it acts as a separate pageblock item, so I can't put it immediately to the right of a field value

2.<apex:outputText label="fieldLabel" value="{!Object.fieldValue} [{!LINKTO(...)}]"/>

This method will display the LINKTO value as part of the field value, which is good. However, LINKTO does not allow me to specify opening a new window.

3.<apex:outputText label="fieldLabel" value="{!Object.fieldValue} [{!HYPERLINK(...)}]"/>

HYPERLINK function does allow me to specific opening a new window, but when trying to use in a visualforce value returns the error problem: Function HYPERLINK may not be used in this type of formula


Now I'm trying to mess with straight HTML (ie the <a> tag), but I'm not sure how to get it to display immediately to the right of the field value.

Your help as always is much appreciated!

1

You can simply use anchor tag to achieve this functionality

<apex:outputText label="fieldLabel" value="{!Object.fieldValue}"/>
<a href="javascript:window.open('url')">
 Change
</a>

And with the use of outputLink:

<apex:outputLink onclick="javascript:window.open('url')">
   Change
 </apex:outputLink>
  • Hah if it's really as simple as putting the anchor tag next to the outputtext tag, I will feel quite silly. Thanks! – smohyee Feb 6 '17 at 23:43
  • Yes, true, please accept and close this question – Santanu Boral Feb 6 '17 at 23:44
  • Santanu, this doesn't solve my issue. The resulting link isn't immediately to the right of the field, like the Ownership field. Rather, it occupies the second column similar to a `<apex:outputLink>'. My use case is to have a 'Description' link next to the field label/value, that can be clicked on for a detailed field description. – smohyee Feb 8 '17 at 6:48
  • But you didn't specified this in your question earlier, anyway good to hear that it solved by panel grid – Santanu Boral Feb 8 '17 at 14:59
0

OK I found a working answer here: Position elements side by side within a single pageBlockSection column

The key is to use an <apex:panelGrid> within a <apex:pageBlockSectionitem>

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.