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

Generic error when creating a Task in a sites page

I have a "contact me" form on a dev site that, upon submission, creates a Task for me.  This works perfectly well inside of SF as a standard Visualforce page, however I get the following error when trying to submit the form on a sites page:

j_id0:j_id1:contactForm:j_id12: An error occurred when processing your submitted information.
j_id0:j_id1:contactForm:j_id15: An error occurred when processing your submitted information. 

Where j_id12 is the Subject input box and j_id15 is the Message input textarea (code below):

<apex:page standardController="Task" extensions="ActivityController" showHeader="false">
 <apex:composition template="PersonalTemplate">
  <apex:define name="body">
   <div id="contact" class="sectiontitle"/>
   <apex:outputPanel layout="block" styleClass="errorDisplay">
    <apex:messages />
   <apex:form id="contactForm">
     <legend>Send questions, comments, or suggestions here</legend>
     <apex:outputPanel layout="block">
      <apex:outputLabel for="subject" value="subject:"/>
      <apex:inputText value="{!Task.subject}"/>
     <apex:outputPanel layout="block">
      <apex:outputLabel for="message" value="message:"/>
      <apex:inputTextArea value="{!Task.description}"/>
     <apex:outputPanel layout="block" rendered="true">
      <apex:commandButton action="{!saveTask}" value="Send" styleClass="submit" style=""/>

public class ActivityController {
 private ApexPages.StandardController controller = null;
 public ActivityController( ApexPages.StandardController controller ) {
  this.controller = controller;

 public PageReference saveTask() {;
  PageReference page = new PageReference( '/apex/PersonalContactSuccess' );
  page.setRedirect( true );
  return page;


As far as I know, all Visualforce pages and Apex classes are available for the site and the site profile.  It acts like there is a security barrier between sites and activities that I cannot change via the site profile.

Any ideas would be much appreciated!

Best Answer chosen by Admin (Salesforce Developers) 
you can create a apex webservice that is accessible via the public site to do this 

All Answers


"Edit Task" permission is required in order to create tasks. Site public access settings doesn't expose this permission.

Can you share more about your use case? Even if you could create tasks via Sites all tasks would belong to the site user. You could crate a task trigger to reassign tasks to other users but then you can do the same with a custom controller as well.
I have a couple use cases that I am working on where it would be nice to have Edit Task capabilities.

The first situation, I have resolved with a custom object.  In this case, I was creating a dummy website with a "Contact Me" form.  When this form was submitted, it would create a Task for the moderator of the website.  To get around this, I created a custom object called CommunicationEntry__c with a few different record types which are used throughout the site, including one for these "Contact Me" requests.  I then created a view in SF that displayed only this record type.  It works, but it would be ideal if I could leverage the existing functionality and have this notification show up in a user's "to do" Task list on the SF home page.

My second situation I am just coming across today.  Currently, there is a bookmark that you can add to your browser that attaches a Google Doc to Salesforce.  We currently switched from MS Exchange to corporate Gmail for our company email service.  Despite this, I am still forced to use Outlook for one very important piece of functionality: adding emails to SF records.  Ideally, I would create a Visualforce page accessible via our org's SF Sites implementation (currently only a DE since Sites is not publicly available) that would take a few parameters (email subject, body, to/from, etc) and build a Task associated with a SF record, functionally similar to Outlook's "Add to SF" add-on.  This page would be called via the bookmark button on the bookmarks toolbar and open the SF Sites page in a new window with the necessary search options to associate it with the appropriate record.

Now, since we are not able to create Tasks via SF Sites, this poses a huge problem.

Here are the possibilities that I came up with (and I would like to hear about any others out there as well!):
  • I could create another custom object to track this information, but that wouldn't really make sense since SF has already standardized the Task as a means of tracking communication history with a record.
  • (If possible) create some ridiculously messy Javascript in the bookmark button that would connect to the appropriate SF org and process the Task creation.
  • A possibility that I haven't explored yet (and am rather unfamiliar with) would be to create an inbound email process that will create these Tasks for me (sans the record association).  I could setup my Gmail account to automatically forward relevant emails to the SF URL that would initiate this process.
  • Is it possible for Apex methods to be called from an external source (as long as the class is included in SF Sites' Enabled Apex Class Access)?
  • Or, is there already a solution out there that handles all of this for me?
Any information on the above would be most helpful!  Thanks in advance.
you can create a apex webservice that is accessible via the public site to do this 
This was selected as the best answer