I need help to write a method which will do some kind of string formatting.
I have list of ids of an object. It may be any object.Like this:
List listContactIds = [select id from contact limit 5];
And I have a certain string format like this:
String format = ‘{name} belongs to {Account.Name}’;
I need to call a method. Suppose the method name is formatString.
formatString(listContacts, format);
The method should be able to return list of formatted strings.Like this Rahul belongs to Google
We can take the exact field names enclosed in {} from the 'format' string
How to acheive this?
Hi,
Ive just tried the below code and it prined some thing similar to what you are looking for. You can change or improve it.
All Answers
Hi,
Ive just tried the below code and it prined some thing similar to what you are looking for. You can change or improve it.
Thanks it helped.
Tweeked the code based on my requirement.This is the working code which will handle relationship fields also: