You need to sign in to do that
Don't have an account?
How to run apex classes without a page?
I've created a class that receives a url and based on it parses all the variables and creates an instances of a custom object in a specific account.
The class works perfectly when called on an apex page. The problem is that I'm sending the url from a server directly to SF and the server doesn't know how to open the page. For this reason the class is never called and the object never inserted.
Is there a way to create a page/process in SF that would create a record without loading a page?
Here are the class and the page I'm referring to.
public class ChatDetail {
And here is the page:
<apex:page controller="ChatDetail" tabStyle="Account" action="{!save}" >
Any help will be appreciated.
Thanks
Tzuvy
|
you can either do it the way you already are, or by exposing it as a webservice and using the ajax toolkit/javascript to get to it. if you're doing this via force.com sites, note that you have security as a factor as well (which you probably saw in setting this up via the page).
Thanks for the quick reply. Can you tell me a little more about the webservice? Or how to make the page run without the need to be loaded?
Basically what I want to do is to run the save function in the constructor but is not possible, I get a DML exception.
How could I set a Web Service? Is this a type of object? Or is it a include in the class?
I will appreciate if you could point me to some tutorial on how to build this kind of solution.
The security I'm passing by sendind the un and pw elements in the url, that is why I changed the splitter in the querying function.
Thanks
Tzuvy
take a look at the apex developer guide. essentially, you define your class as global, and your desired method as a webservice. you can then have your server connect to the API, instead loading a web page. you didn't really provide much detail on why the server can't load a page/what type of server it is, etc, so just throwing out suggestions.