Monday, June 29, 2020

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 a workaround

Sample Code
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);

1 comment: