function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
baller4life7baller4life7 

OutputLink does not show up in Site

Hey guys,

the following code gives me headaches:

 

<apex:pageBlockTable value="{!tasks}" var="task" id="table" style="width:100%;">
        <apex:column >
            <apex:facet name="header">Related Object</apex:facet>
            <apex:outputLink value="https://na4.salesforce.com/{!task.What.Id}">{!task.What.Name}</apex:outputLink>
        </apex:column>
...

 The link in the table column should lead directly to the detail page of the "WhatId" object of the task.

 

The funny thing is that the links show up correctly in a normal visualforce page within SFDC. But as soon as I use the page in a public site, the links won't show up... What's the problem here?

 

Thank you in advance

Aljoscha

Best Answer chosen by Admin (Salesforce Developers) 
Shashikant SharmaShashikant Sharma

I think you did not get My point I wanted to say you create a wrapper Class like

 

 //Fill this lsit with your task 

public List<taskWrapper > listTaskWrapper

{  

      get

      {

                   if(listTaskWrapper == null)

                          listTaskWrapper = new List<taskWrapper>();

                  

                   return listTaskWrapper ;

       }

      set;

}

 

public Class taskWrapper {

 

Public String taskWhatId {get;set;}

Public String taskWhatName {get;set;}

 

public taskWrapper(Task t)

{

    this.taskWhatId  = t.what.id;

    this.taskWhatId  = t.What.Name;

 

}

 

 

}

 

//Fill this listTaskWrapper  with your task 

for(Task t : Tasks)

{

       listTaskWrapper.add(new taskWrapper(t));

}

Now your VFP should have table like this

 

<apex:pageBlockTable value="{!listTaskWrapper}" var="task" id="table" style="width:100%;">
        <apex:column >
            <apex:facet name="header">Related Object</apex:facet>
            <apex:outputLink value="https://na4.salesforce.com/{!task.taskWhatId}">{!task.taskWhatName}</apex:outputLink>
        </apex:column>

 

Please let me know if you have any issue in it.

All Answers

Shashikant SharmaShashikant Sharma

Do this

 

1) IN your controller , Create a String geeter method or property.

 

like

public string getTaskWhatName()

{

return task.What.Name;

}

 

in your VFP rather than using {!task.What.Name} in OutputLink please use

 

<apex:outputLink value="https://na4.salesforce.com/{!task.What.Id}">{!TaskWhatName}</apex:outputLink>

 

 

 

baller4life7baller4life7

Hello Shashikant,

thank you for your effort, but your solution does not work, because "task" is only a temporary variable of the dataTable. Therefore I can not write a getter method!

Shashikant SharmaShashikant Sharma

I think you did not get My point I wanted to say you create a wrapper Class like

 

 //Fill this lsit with your task 

public List<taskWrapper > listTaskWrapper

{  

      get

      {

                   if(listTaskWrapper == null)

                          listTaskWrapper = new List<taskWrapper>();

                  

                   return listTaskWrapper ;

       }

      set;

}

 

public Class taskWrapper {

 

Public String taskWhatId {get;set;}

Public String taskWhatName {get;set;}

 

public taskWrapper(Task t)

{

    this.taskWhatId  = t.what.id;

    this.taskWhatId  = t.What.Name;

 

}

 

 

}

 

//Fill this listTaskWrapper  with your task 

for(Task t : Tasks)

{

       listTaskWrapper.add(new taskWrapper(t));

}

Now your VFP should have table like this

 

<apex:pageBlockTable value="{!listTaskWrapper}" var="task" id="table" style="width:100%;">
        <apex:column >
            <apex:facet name="header">Related Object</apex:facet>
            <apex:outputLink value="https://na4.salesforce.com/{!task.taskWhatId}">{!task.taskWhatName}</apex:outputLink>
        </apex:column>

 

Please let me know if you have any issue in it.

This was selected as the best answer
sravusravu

Hi,

 

When you are trying to display the link in the site you should make sure that you are giving the correct site url.

 

 <apex:outputLink value="https://na4.salesforce.com/{!task.What.Id}">{!task.What.Name}</apex:outputLink>

 the url you have mentioned in the value is the salesforce url which will require login for external users to access.

You will have to give your site url. or else for this to work on both the site and internal salesforce, get the currentpageurl from the controller and give that url in the outputlink.

 

Let me know if you have any concerns.



baller4life7baller4life7

Hey guys,

thank you for your recommendations, but the problem is something else...

The problem is independent from the outputLink component. It doesn't work for outputText, too...

So I guess it has soemthing to do with the "What" field

 

This is my query:

 

SELECT Id, What.Name, WhatId, Subject, Type, Description, ActivityDate, Who.Name, WhoId, Status
FROM Task

 

In my site the What.Name, WhatId, WhoId and Who.Name fields do not show up... Why?

sravusravu

Hey got it, you cannot get Tasks and events on site. That is the reason you are not able to get that link work on site and it works fine internally.

baller4life7baller4life7

No, I can show the information of tasks in my table... Subject, Description, everything is fine... except WhatId, What.Name, WhoId, Who.Name!

sravusravu

can you try querying what.Id and see instead of what.name if what.Id works

sravusravu

Hi,

 

Can you check the profile settings for the authenicated site once.

Shashikant SharmaShashikant Sharma

Does your query returns the values in controller, if yes than I am sure wrapper class solution will work no doubt about it. If you are not geeting values in controller than make your controller without sharing class and use wrapper also.

 

Please let me know aout wrapper result.

baller4life7baller4life7

Hooray! Shashikant's solution with the wrapper class worked well for me!

Thank you very much for your effort!

 

But I have one last question for you, Shashikant:

Can you please explain why the wrapper class is neccessary? I want to learn for the future!

Shashikant SharmaShashikant Sharma

your welcome baller4life7