You need to sign in to do that
Don't have an account?

DML Currently not allowed
Hey all,
I'm trying to make a component for adding inline notes to any record.
But each time I call the {!addNote} action, I get "System.Exception: DML currently not allowed"
I don't know why that is, some explanation would be hot.
Here is my controller:
public class GenericInlineNoteComponentController { // External variables public List<Note> n {get; set;} public String myObjectId {get; set;} public GenericInlineNoteComponentController() { Id thisId = myObjectId; n = new List<Note>(); Note newNote = new Note(); newNote.ParentId = thisId; //Add the new line right off the bat n.add(newNote); } //Save public PageReference addNote() { insert n; return null; } }
Everything displays correctly till addNote is called.
Thanks,
JNH
Hello JNic;
I dont think that the problem is with your "addNote()" method.The problem is may be with the place where you call the "addNote()" method. In some places it is not allowed to do DML operations. For an example in your constructor you cant do a DML operation(So you can't call the "addNote()" method in constructor). Could you please tell us how/where do you call the "addNote()" method.
If you want to use dml statements in a component you have to use the allowDML attribute in the visualforce component tag:
<apex:component allowDML="true"> ...
Is this Visualforce Component? If yes you can add allowDML="true"
Refer this: http://salesforce.stackexchange.com/questions/32138/system-limitexception-dml-currently-not-allowed
Thanks
Hari