Inserting a task from a Force.com Site

I have a Force.com Site with a controller inserting a new Task. I noticed that I receive no error on the page, but the Task is not created. When I access to the same page internally (from https://.../apex/myPage), the Task is created.

I noticed that there’re no check boxes to allow Activity/Task/Event creation. So my question: is it possible?

Thanks.

UPDATE 2013-03-05

Here’s my controller. The method handler is called using the action="handler" from <apex:page>

public with sharing class Testing {

    public PageReference handler() {
        Task act = new Task(
            RecordTypeId    = '012c00000000fCS',
            Subject         = 'Testing'
        );

        try {
            insert act;
        } catch (DmlException e) {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Error:' + e));
        }

        return null;
    }
}

Answer

Unfortunately this is not possible because the “Edit Task” permission is required in order to create tasks. Site public access settings doesn’t expose this permission. You would have to write an Apex Web Service to accomplish this.

Check out this article from Salesforce to help get you started on a Web Service.
http://wiki.developerforce.com/page/Apex_Web_Services_and_Callouts

Attribution
Source : Link , Question Author : jpmonette , Answer Author : jonnybro

Leave a Comment