Apex · Salesforce

How to convert Set Id to Set String in Apex code?

Apex code is not supporting converting set<Id> to set<String> direct way – we have to do workaround –

Set<Id> ids = new Set<Id>{'001G0000023lIWq','a61G0000000TOSE'};

Set<String> idStrs = (Set<String>)JSON.deserialize(JSON.serialize(ids), Set<String>.class);

System.debug('idStrings=' + idStrs);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s