+ Start a Discussion
Justin MitchellJustin Mitchell 

How can I link to a user or a queue depending on which is the owner?

This is probably very simple but I'm having trouble figuring out the syntax. I am trying to display a link to the record owner's record on a visualforce page. If it's a user, the link should be 
If it's a queue I believe it should be

I have tried to add this conditionally into the outputLink but I either get a syntax error one way, or I get a bad url. 
Here's one thing I've tried:
<apex:outputLink value="{!IF( ws.Owner.Type = 'User', '/{!ws.Owner.id}', '/p/own/Queue/d?id={!ws.Owner.id}')}" target="_blank"> {!ws.Owner.Name} </apex:outputlink>

The resulting urls generated from the code above is

Question 1: Is there a simpler way to link to the Owner's record than using conditional output (ie: <apex:outputLink value="/{!ws.Owner.IdNoMatterIfTheyAreAUserOrAQueue}"> )?

Question 2: If not, what is the proper syntax to use when trying to insert variables (might not be the correct terminology) into a condtional statement?


Vivek DVivek D
In IF try correcting the syntax 
IF( ws.Owner.Type == 'User',
Justin MitchellJustin Mitchell
I should be more clear. The logic works perfectly. If I do this:
value="{!IF( ws.Owner.Type = 'User', 'http://www.google.com', 'http://www.yahoo.com")}
then the the result will be that clicking on a user will take me to google.com, and clicking on a queue will take me to yahoo.com.

The part I can't figure out is how to get the resulting link to come out as "salesforce.com/906F0000000MMcK" instead of "salesforce.com//{!ws.Owner.id}"
Justin MitchellJustin Mitchell
So I found one workaround, but it's ugly and I would love know if there's a more elegant solution:
     <apex:outputLink value="/{!ws.Owner.id}" target="_blank"
     rendered="{!ws.Owner.Type = 'User'}">                   
     <apex:outputLink value="/p/own/Queue/d?id={!ws.Owner.id}" target="_blank" 
     rendered="{!ws.Owner.Type = 'Queue'}"> 
This puts two hyperlinks into the same cell of the table, but only shows one of them depending on whether the owner is a User or a Queue.