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

DML insert halting Apex script in Sites Controller
I have a very odd problem with some dml code. I have a form on a Sites site which creates Leads. The submit action of the form is just halting when I come to insert the new Lead; no exception is thrown and no further processing takes place. A code snippet:
try {
Lead l = new Lead(LastName = 'foo', Company = 'bar', Status = 'Open - Not Contacted');
Database.insert(l,false);
System.debug('Lead saved');
} catch (Exception e) {
System.debug('Exception caught');
System.debug(e);
}
Neither 'Lead saved' nor 'Exception caught' appears in the debug log, the log just ends:
20090822071712.927:Class.SitesLoopBlog.WebFormController.saveObject: line 96, column 14: Insert: SOBJECT:LeadCumulative profiling information:
And I get the dreaded Authorization Required page. Any ideas?
Addition to crud and fls checks, aso check if you are performing this dml via a component. If yes then you need to enable DML for your component
All Answers
Addition to crud and fls checks, aso check if you are performing this dml via a component. If yes then you need to enable DML for your component
Hello Bulent,
I have the same issue when attempting to insert leads.
But how do I "enable DML via a component"?
Do I add a special keyword to the class definition?
Thanks!
Erik
<apex:component allowDML="true">
Thanks Bulent,
Pretty elementary, sorry to waste your time on that, but it is appreciated.
Still working on this issue, more comments later.
Something I did find was that, while I can edit Field Level Security (FLS) from the Sites page, via the Public Access Settings button (which takes you to a profile screen of the guest user specifically for this site), when I went to the Field Accessibility settings under the Administration Setup menu, and checked out the FLS for the "Standard Guest User" profile, I found most of my fields were marked as hidden... changing these to editable did not fix my issue, but I found it interesting....
Erik
Hi Bulent,
For me its stillnot working. I have a visual workflow which insert Leads and this flow is being called from vf page. I have created a site and when this page launches it works well but when it reaches to Flow step where Leads are inserted, it gives error Authentication required. Please guide.
Thanks in advanc,
san