Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Can I run following code after login as customer portal user in apex controller?

task.WhatId = Object.id;
task.WhoId = Object.Editor__c;
task.Subject = 'Other';
task.priority= Object.Priority__c;
task.status = 'Not Started';
task.description = 'New  Work';
insert task;

I am getting error "Currently DML is not allowed". I want to create a task for customer portal user. Is that possible? I don't want show it to any user. I will just use it to send notification email. Is there any way to do so?

share|improve this question
add comment

2 Answers 2

up vote 5 down vote accepted

Well seems like you are doing DML from either Constructor or Getter method. Please try to do the same from action attribute of the page by calling a method

share|improve this answer
    
I am calling an action method from VF page and action method calls this code. Please note context user is customer portal user. –  doga Feb 28 '13 at 3:47
add comment

There's a blog post about this from Wes Nolte that even contains a short poem:

http://th3silverlining.com/2009/11/23/dml-currently-not-allowed/

This covers all of the scenarios and solutions for each of them.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.