function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kathybbkathybb 

Get an object ID from a PageReference

I'm using a standard Controller's save action (called by sc.save()) to save a new record.  It returns a PageReference called OrderPage.  When I look at the returned PageReference in the debugger, it is the ID of the saved record preceded by a '/'.  I need to assign the id (without the '/' to a variable for further processing.  The page hasn't loaded, and in any event OrderPage.getParameters().get('id) doesn't work nor does (getting desperate here) OrderPage.valueOf() or various attempts at using string functions to extract it.

 

Can anyone tell me how to do this?  It seems like it would be a common use case, but a lot of searching both here and on the Internet has been unsuccessful.

 

I appreciate any help anyone can offer.

Best Answer chosen by Admin (Salesforce Developers) 
kathybbkathybb

It turns out I was approaching the problem from the wrong angle --I needed to call getId() on the standard controller, and it was nothing to do with the PageReference.at all.  Thanks for your willngness to help.