You need to sign in to do that
Don't have an account?

Convert ID to string?
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?
Haven't tested it completely but give this a go.
All Answers
Haven't tested it completely but give this a go.
You can also use String.valueOf(entry.Pricebook2Id)+String.valueOf(entry.Product2Id).
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!
I wanted to Used the Salesforce ID conversion in Visualforce.
trigger UpdateACNameonInsert on Contact (before insert) {
for(Contact c:Trigger.new)
{
c.Account_Name__c=String.valueOf(c.AccountId);
}
}Please help in this regard.
What field type is 'c.Account_Name__c' in your org? If it is a lookup field pointing to your Account object, then you should put the ID value in there directly, not the string value of the ID.
Just add a dash so that it looks like this: myMap.put(a.id + '-' + oid, something); and it will work.