Find your content:

Search form

You are here

Viewing and Inserting a Task from Force.com Site

 
Share

The below VF page queries for a list of tasks assigned to a certain custom record. It works perfectly fine (shows 3 Tasks) when accessed by an internal user (/apex/siteTasks?id=xxx) while it does not show any data when the same page is accessed through Force.com Site. I have checked the usual suspects like CRUD, FLS, VF page access to the Site profile. Debug logs on the site user shows that the query in the Apex Class is returning data but the VF does not show it. Thanks in adv!

VF Page

<apex:page standardController="Cust__c" extensions="siteTasks">
<apex:pageBlock title="Tasks">
    <apex:pageBlockTable value="{!Tasks}" var="tsk">
        <apex:column title="Subject" value="{!tsk.Subject}" />
        <apex:column title="Status" value="{!tsk.Status}" />
    </apex:pageBlockTable>
</apex:pageBlock>

Extension

public class siteTasks {

  public Cust__c inc {get; set;}
  public List<Task> Tasks {get; set;}

  public siteTasks(ApexPages.StandardController ctrl) {
    cust = (Cust__c) ctrl.getRecord();

    Tasks = [SELECT ID, Type, Subject, Status
                FROM Task
                WHERE WhatId =: cust.id];
  }
}

Attribution to: DCBoy

Possible Suggestion/Solution #1

By default, Organization-Wide Defaults (OWD) for Activities (the collective name for Tasks and Events) are set to 'Private', so no user (except for a System Administrator, who has 'View All Data' permission) should be able to see any other user's Tasks, except via the role hierarchy (manager can see their underlings' tasks).

You could try sharing the Task records with the Site guest user, though I'm not sure if this is even possible, otherwise, you'll need to set OWD for Activities to Public Read Only.


Attribution to: metadaddy

Possible Suggestion/Solution #2

does the site user have permission to the Cust__c object, any fields, and access to the activities and its fields?

When stuff in VF is blank, but you don't get the login page, that usually means, "You've got object permissions so that page loads, but I'm going to hide the fields from you"

Can you try displaying some information on the page about the cust__c? That at least proves the permisssions aren't the issue.


Attribution to: Shane McLaughlin
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/30727

My Block Status

My Block Content