I've got an apex class with a webservice method that I'm trying to fire from a custom button on the page layout of the object the method will be doing stuff to.
My javascript for the custom button that fires the Apex webservice is pretty basic:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
var myvar = sforce.apex.execute("ActOn_Scheduled", "UpdateMsgStats", {msg: {!THIS.SOBJECTRECORD}});
As the code above shows, one of the parameters to my "UpdateMsgStats" method is 'msg', which is the actual record for the custom sObject "Message". I've stuck in the fake merge field "{!THIS.SOBJECTRECORD}" as a placeholder to give you all an idea of what I'm looking for.
I suppose I could pass the record's ID instead, and use a SOQL query to get the actual sObject record back, but I'm wondering if there's a way to pass the entire object using a merge field, or something similar?
edit: is the proper merge field by chance "{!$ObjectType.mycustomobject__c}"? Never used that one before...
Another related question: there's actually a second parameter to this method, the oAuth access token in the form of a string. I have a separate method in the class that makes an API callout to get the string and stores it in a variable in the actual class. Is there a way to pull a variable from the referenced class and pass it via the javascript button? Or should I just call the authorization method within the webservice?