I have this method below that Returns a String of Id's separated by '|' operator and it works. However now I would like to add on that if an Id is null or blank replace with just single quotes (''). Not sure how to do that. How can i modify this method to do that.
I expect just to see the single quotes only. Example if have strings of ids my result = ('46734'|'3435') What I am looking for if no Ids then I would like to see result =('') or (''|'') not result = ()
public static string getString(Set<Id> setId)
{
String strId = '';
if(setId != null && setId.size() > 0 )
{
for(Id RecordId :setId)
{
String strRecordId = RecordId;
if(strRecordId.length() > 15){
strRecordId = strRecordId.substring(0,15);
}
strRecordId = '\''+ strRecordId + '\'';
strId += strRecordId + '|';
}
strId = strId.removeEnd('|');
}
return strId;
}