Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Apex Code Development
- :
- Convert ID to string?
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Convert ID to string?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-05-2013 03:38 PM
I want to concatenate two object IDs in order to make a hash value for a map, but this doesn't work:
conversionMap.put(entry.Pricebook2Id + entry.Product2Id), entry);
If I could convert the IDs to strings first, then I should be able to concatenate them in this way. But, while there is a function to convert a string to an ID, I can't find any way to convert an ID to a string. Anybody know how to do that? Or, a better way to do what I'm trying to do?
Solved! Go to Solution.
Re: Convert ID to string?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-05-2013 04:32 PM
Haven't tested it completely but give this a go.
String newID = '' + entry.pricebook2Id + entry.Product2Id;
Re: Convert ID to string?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-05-2013 06:25 PM
You can also use String.valueOf(entry.Pricebook2Id)+String.valueOf(
~ sfdcfox ~
I am a sandwich. That is all.
Re: Convert ID to string?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-06-2013 09:18 AM
Thank you both for your quick replies. I tested both methods and they both worked.
I swear I had already tried String.valueOf() and I got an error. But when I tried it again now, it worked. User error!

