Apex Map with comma separate value

Apex Iterate the map value and separate with comma

if(Trigger.isUpdate && Trigger.isAfter){
        Map<string,string> caseshopID = new Map<string,string>(); 
        for(case itr:trigger.new){
            if(itr.Case_Record_Type__c=='Additional Visa/GVAC' && itr.AdditionalQuotaRequest__c){
                caseshopID.put(itr.id,itr.Shop__c+','+itr.Additional_Quota__c);
            }
        }
        if(caseshopID.size()>0){
            caseglobalHelperClass.updateShopQuota(caseshopID);
        }
    }


public static void updateShopQuota(Map<string,string> caseshopid){

        set<string> shopID = new set<string>();
        Map<string,string> mapQuotaNum = new Map<string,string>();
        for(string a:caseshopid.values()){
            List<string> b=a.split(',');
            string c = string.join(b,',');
            List<String> d= c.split(',');
            system.debug('-------'+d[0]+'-----'+d[1]);
            shopID.add(d[0]);
            mapQuotaNum.put(d[0],d[1]);
        }
     
        List<Shop__c> updateshpList = [select id,IncreasedQuota__c from Shop__c where id IN:shopID];
        for(Shop__c itr:updateshpList){
           itr.IncreasedQuota__c  = Integer.valueof(mapQuotaNum.get(itr.Id));
        }
     
        if(updateshpList.size()>0){
            update updateshpList;
        }
    }

No comments:

Post a Comment