You need to sign in to do that
Don't have an account?
How to enable DML for Controller? (DML in method invoked by Visualforce page action fails)
I am hoping this is an easy question:
I am invoking an
"action" when a visualforce web page is loaded.
<apex:page contentType="text/xml" controller="MyPageController"
action="{!MyUpsertAction}" showHeader="false">
From
extensive tracing and debugging, I know MyPageController is working and
MyUpsertAction is working
up until the moment it tries to do an
"upsert".
I can't figure out how to allow DML operations
initiated through a web/visualforce page.
I get the dreaded
"Authorization Required" page displayed (instead of the XML my page
should be serving up).
I also get an error message sent by email.
Apex script unhandled exception by user/organization:
005A0000000IePu/00DA0000000Jcjx
Visualforce Page: /
caused by: System.Exception: DML currently not allowed
I am
sure there is a quick fix by clicking some option somewhere on
Saleseforce,
but I am really pulling my hair out trying to find it!
Please
be specific about the steps I need to follow to solve this problem.
I am new to developing on Salesforce, so if you just say "enable DML for the site",
I won't have a clue where to navigate and click on the Salesforce web pages.
Any suggestions would be
appreciated.
David Jones
dxjones@gmail.com
Hello David,
did you find the problem? I have the same problem in a Visualforcepage rendered as PDF. Normally you should have a pagereference method in your page. There DML statements are allowed. But in a controller for a PDF a pageReference makes no sense, so I have the same problem as you!
Thanks
Harry
For me I found the solution! I wrote a pageference method with return null!
Harry
I'm running into the same wall. Could you post your controller code HarryHH?
Error: Method is not visible: [cres_cc_HeaderController].InActiveLightFixtureCart()
Error: Error occurred while loading a Visualforce page.
Visual Force page
<apex:page id="CSTN_Global_Header" applyHtmlTag="false" docType="html-5.0" sidebar="false" showHeader="false"
standardStylesheets="false" controller="cres_cc_HeaderController" action="{!InActiveLightFixtureCart}">
Controller:
global with sharing class cres_cc_HeaderController {
public cres_cc_HeaderController(){
}
public PageReference InActiveLightFixtureCart(){
//System.debug('InActiveLightFixtureCartsByUserId - ccrz.cc_CallContext ' + ccrz.cc_CallContext.currUserId);
System.debug('InActiveLightFixtureCartsByUserId - ccrz.cc_CallContext5');
System.debug('InActiveLightFixtureCartsByUserId - ccrz.cc_CallContext5 ' + ccrz.cc_CallContext.currUserId);
return null;
}
}
Please guide