You need to sign in to do that
Don't have an account?
Seraph
Q>How to fix “DML currently not allowed” when Accessing Visualforce Page
I edited my class and saved it successfully but when I accessed my page which uses the class, I get an error of
DML currently not allowed
An unexpected error has occurred. Your development organization has been notified.
controller
Thanks in advance !
DML currently not allowed
An unexpected error has occurred. Your development organization has been notified.
controller
public class DefinitionController { public DefinitionController() { this.DefTable(); } public void DefTable(){ listplatforms = [select Name,Status__c from Platform__c]; for(Platform__c idlistplatforms : [select Id from Platform__c]){ List<Def__c> existplatforms = [select Platform__c from Def__c where Platform__c=:idlistplatforms.Id]; if(existplatforms.size() > 0) { idlistplatforms.Status__c = 'Set'; //update idlistplatforms; System.debug('Found'+ idlistplatforms); } else { idlistplatforms.Status__c = 'Not Set'; //update idlistplatforms; System.debug('Not Found'+ idlistplatforms); } update idlistplatforms; } } }I think the problem is because of the update part. How do I overcome this error?
Thanks in advance !
With following VF:
If its helps, please mark as best answer so it will help to other who will serve same problem.
Thanks!
All Answers
Alternatively;
- Remove statement this.DefTable(); from Contrustor.
- Change return type of DefTable() to be PageRefernce and return null from this method.
- Add action attribute in VF page's <apex:page> tag. i.e <apex:page controller="DefinitionController" action="{!defTable}" > ... </apex:page>
Hope this will resolve your issue.
Thanks
Usman
Visualforce Page Don't forgot to comment the code where you are callin the DefTable method in your controller.
Thanks,
Karanraj (http://www.karanrajs.com)
With following VF:
If its helps, please mark as best answer so it will help to other who will serve same problem.
Thanks!
Thanks
@Usman Aslam..my bad..I forgot this part Remove statement this.DefTable(); from Contrustor. It worked.
@Shrikant Bagal..thanks for replying. I didn't know it was that simple.
After spending some time on the code, I think its better to put it on an apex trigger instead.
How will I do this?
Thanks!
Actually I have tried similar way, But I am getting issue as
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
I am getting same type of error in omniscripts,
when I am opening omniscripts i am getting
vlocity_cmt:DML currently not allowed
An unexpected error has occurred. Your solution provider has been notified. (vlocity_cmt)
this error