I am trying to pass the record ID from a button, clicked on a custom object, in salesforce, to both an APEX class and to a visual force page...
My button has the following code:
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}
var visualForcePage = sforce.apex.execute("TestController", "getID", {myId : '{!ECS__RMA__c.Id}'});
var informationFetch = sforce.apex.execute("TestLabel", "execute", {myId : '{!ECS__RMA__c.Id}'});
window.open('/apex/TestLabel');
On the TestLabel visualforce page I have the following code:
<apex:pageBlock title="Select return address for {!RMA}">
In the controller I have:
(to get the Id of the record the button was clicked on)
webservice static void getID(Id myId){
System.debug(myId);
myIdclone = myId;
}
(and to get the text associated with RMA)
public static string getRMA(){
System.debug('ID: ' + myIdclone);
TestMethods job = new TestMethods();
String rmaNumber = TestMethods.getRMA(myIdclone);
return rmaNumber;
}
On TestMethods I have:
public static string getRMA(Id recordId){
sObject rmaSOBJECT = [SELECT Name FROM ECS__RMA__c WHERE Id =: recordId];
String rmaNumber = (String)rmaSOBJECT.get('Name');
return rmaNumber;
}
My error is:
18:11:04:055 FATAL_ERROR System.QueryException: List has no rows for assignment to SObject
18:11:04:052 USER_DEBUG [16]|DEBUG|ID: null
I believe my problem is coming from the deletion of the cache of the variables upon code execution. My question is: How can I get getRMA on the controller to properly use the myID variable previously assigned by the javascript?
I apologize if this code is cluttered, I am fairly novice at apex visualforce programming.