Notifications
Clear all
Sep 04, 2021 7:33 am
Create string values to be used in the IN Clause of a WHERE condition in SOQL
1 Reply
Sep 04, 2021 7:34 am
jsonBody = '[{"count__c":"445", "downloads__c":"340"}, {"count__c":"440", "downloads__c":"240"}]'; List dList = (List) System.JSON.deserialize(jsonBody, List.class); countList has unique count__c values, say: 445,440 // to use in the IN clause. // Create a string of unique plan ids to use in the IN clause set<String> sSet = new set<String>(); String strCounts = ''; for(Data__c d : dList) { sSet.add(d.count__c__c); } for(String ss : sSet) { strCounts += ss+','; } strCounts = strCounts.removeEnd(','); list<String> countList = strCounts.split(','); // to use in the IN clause // Querry parent for those plan ids in daily data json List<Parent__c> cList = [SELECT Id, Name, Count__c FROM Parent__c WHERE count__c IN countList];