function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
basha skbasha sk 

How to seperate the fields from respoonse and map with other object?


        Hi Everyone,

         I'm trying to map the response value to other object but i'm stucked at separeting the each value from response
         if anybody having idea please let me know.

        
        Map<String,String> test = new Map<String,String>();
        Map<String,String> sample = new Map<String,String>();  

        List<String> orderList = new List<String>();

        for(String t :sample.keySet()){                     
          String tt = sample.get(t);                    
        for(String s :test.keySet()){                      
            String ss = test.get(s);                        
               if(tt.equals(s)){                                           
                   orderList.add(ss);
                   System.debug('OrderList:::'+orderList);
               }
        }
        }
                        
        I got the orderList Response like below

        Response : Kalyan K                
        Response : Kalyan K, Kalyank@tcs.com
        Response : Kalyan K, Kalyank@tcs.com, Attended
        Response : Kalyan K, Kalyank@tcs.com, Attended,Chennai    
        Response : Kalyan K, Kalyank@tcs.com, Attended, Chennai,Tamilnadu
        Response : Kalyan K, Kalyank@tcs.com, Attended, Chennai, Tamilnadu, India            
        Response : Kalyan K, Kalyank@tcs.com, Attended, Chennai, Tamilnadu, India, 9857455552

        how can i seperate the each value for assigining to the other object like  below

        Lead le = new Lead();
        le.LastName = ss;// here map kalyan k
        le.LightiningEd__AdobeEmail__c = ss; // here map Kalyank@tcs.com
        le.Status = ss; //here map Attended
        le.LightiningEd__City__c = ss; // here map Chennai
        le.LightiningEd__State__c = ss; //here map Tamilnadu
        le.LightiningEd__Country__c = ss; here map india
        le.MobilePhone = ss;  //here map 9857455552                            
        LeadList.add(le);

        Please anybody having idea share with me.

        Regards,
        



















 
Best Answer chosen by basha sk
v varaprasadv varaprasad
Hi Basha,

Please check sample code below.
for(String t :sample.keySet()){                     
          String tt = sample.get(t);                    
        for(String s :test.keySet()){                      
            String ss = test.get(s);                        
               if(tt.equals(s)){                                           
                   orderList.add(ss);
                   
               }
        }
 }
 
 System.debug('OrderList:::'+orderList);
 
 if(orderList!= null){
     for(integer i = 0 ; i <= orderList.length() ; i++){   
	    Lead le = new Lead();
        le.LastName = orderList[0];// here map kalyan k
        le.LightiningEd__AdobeEmail__c = orderList[1]; // here map Kalyank@tcs.com
        le.Status = st[2];//here map Attended
        le.LightiningEd__City__c = orderList[3]; // here map Chennai                         
        LeadList.add(le);
	
	}
 }


Hope this helps you!

Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com




 

All Answers

v varaprasadv varaprasad
Hi Basha,

Please check sample code below.
for(String t :sample.keySet()){                     
          String tt = sample.get(t);                    
        for(String s :test.keySet()){                      
            String ss = test.get(s);                        
               if(tt.equals(s)){                                           
                   orderList.add(ss);
                   
               }
        }
 }
 
 System.debug('OrderList:::'+orderList);
 
 if(orderList!= null){
     for(integer i = 0 ; i <= orderList.length() ; i++){   
	    Lead le = new Lead();
        le.LastName = orderList[0];// here map kalyan k
        le.LightiningEd__AdobeEmail__c = orderList[1]; // here map Kalyank@tcs.com
        le.Status = st[2];//here map Attended
        le.LightiningEd__City__c = orderList[3]; // here map Chennai                         
        LeadList.add(le);
	
	}
 }


Hope this helps you!

Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com




 
This was selected as the best answer
basha skbasha sk
thank you so much varaprasad here instead length() i'm using size() it works like a charm
v varaprasadv varaprasad
Hi Basha,

Above information is informative and helps you please mark it as the best answer.

    Thanks
    Varaprasad
    For Support: varaprasad4sfdc@gmail.com