You need to sign in to do that
Don't have an account?
bohemianguy100
Return PageReference from a webservice method
I have a custom button that executes javascript.
{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/24.0/apex.js")} sforce.apex.execute("TestClass","CreateTestRecords", {id:"{!Case.Id}"});
In my apex class I want to return a PageReference to the same page from where the custom button was clicked (refreshing the page). Is that possible using a webservice static method?
global class TestClass { WebService static void CreateTestRecords(String caseId) { List<Fulfillment__c> fulfillmentsToCreate = [select Id from Fulfillment__c where Case__c =: caseId]; if(!fulfillmentsToCreate.isEmpty() && fulfillmentsToCreate.size() > 0) { insert fulfillmentsToCreate; } } }
I was trying to avoid using a VF page and just handle everything in a controller. Is that possible?
Thanks.
I have a very similar issue with webservice.
maybe we can use JS to refernce the user to the right page...?
In your Class use a String as a Returntype
and create your reference like this in your webservice class
and in your Button, you have to catch your return String and reload the page: