Saturday, November 21, 2015

How to Return PageReference from a webservice method

In your Class use a String as a Returntype
and create your reference like this in your webservice class
return String.valueOf( new PageReference('/'+Case.Id).getUrl());
and in your Button, you have to catch your return String and reload the page:
var newurl = sforce.apex.execute("TestClass","CreateTestRecords", {id:"{!Case.Id}"});
parent.location.href = newurl; //refresh the page

1 comment:

  1. Can we redirect the page the same way to the edit page of the record ??

    ReplyDelete