function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Tena W.Tena W. 

Create Case on page load Error

I have a page that on load pulls from an outside webservice.  This webservice may have issue and therefore won't display data.  I display an error to the user but I want to create a case that is assigned to a group of people in the compnay so it can be worked on.  I am unable to create a case when the page is being loaded due to DML restrictions. 

My Idea: create a checkbox and have it check so that when the error is caught it is cheked and initiates the action method.  This doesn't seem to work as I had planned.

Is anyone doing this and how?
Best Answer chosen by Tena W.
Gigi.OchoaGigi.Ochoa
If you run your code to pull web service data through a page action, instead of through the constructor, you should be able to do DML on page load.

All Answers

Ramu_SFDCRamu_SFDC
You can probably try using a custom button that would create another case with somee information passed from this page during error. Follow below post to know how to code custom button

https://developer.salesforce.com/forums/ForumsMain?id=906F00000008p2MIAQ
Tena W.Tena W.
I don't want the user to press anything.  I want to create it behind the scenes.  Sorry I should have said that the checkbox is a hidden one that I set.  If the box is set then create the case. 
Ramu_SFDCRamu_SFDC
I assume that the case deatail page in question is a standard page with VF embedded in it.  If this is the case, I do not think there is someway to automatically create another record in the background on page load without any action by the user.  But we can never say it is impossible as there might be some other way around. Let's wait if anyone else have any thoughts on this.
Gigi.OchoaGigi.Ochoa
If you run your code to pull web service data through a page action, instead of through the constructor, you should be able to do DML on page load.
This was selected as the best answer
Tena W.Tena W.
That was it.  I didn't think of that..thanks