?
Solved

how to extract an objectID from a PageReference?

Posted on 2013-06-01
5
Medium Priority
?
268 Views
Last Modified: 2016-02-17
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.
0
Comment
Question by:kathytb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 15

Expert Comment

by:ChloesDad
ID: 39213462
Here are examples of how to split a string. You should be able to remove the '/' and then use the rest.

http://boards.developerforce.com/t5/Apex-Code-Development/String-split-method-works-only-some-of-the-time/td-p/185684
0
 

Author Comment

by:kathytb
ID: 39213561
Thanks for your suggestion -- that was one of the things I had tried.  The problem is that save() returns a PageReference object (array, I think) and I haven't found a way to extract the ID so I can work with it as a string.  I really appreciate your willingness to help.
0
 
LVL 15

Expert Comment

by:ChloesDad
ID: 39213582
To refer to an item in an array you use [ ] notation, so if you array is called myArray then myArray[0] will be the first element (if its zero based)
0
 

Accepted Solution

by:
kathytb earned 0 total points
ID: 39214415
I was barking up the wrong tree entirely, I'm afraid.  It turns out I needed to call getId() on the controller, not anything on the PageReference.  I really appreciate your suggestions -- thank you for helping me out.
0
 

Author Closing Comment

by:kathytb
ID: 39228393
I was approaching the problem from the wrong angle.
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: You must have administrative privileges in order to configure lead or case queues. Salesforce.com (http://www.Salesforce.com) is a cloud-based customer relationship management (CRM) system. It is widely used around the world by sales and ma…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question