• Miriam Caldwell 4
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi, 
I'm very new to APEX so please bear with me.  I have 2 different map strings objects and I'm trying to concatenate them using the map method .putAll, however it's replacing instead of concatenating.   

if(aresp.getBody() != null ||  bresp.getBody() != null ){
                Map<String, Object> aretVal;
                Map<String, Object> bretVal;
                if(aresp.getBody() != null)
                {
                    System.Debug('****** raw a Response: ' + aresp.getBody());
                    aretVal = (Map<String, Object>) JSON.deserializeUntyped(aresp.getBody());
                }
                System.Debug('****** aretVal: ' + aretVal.size());
                System.Debug('****** aretVal: ' + aretVal);
                if(bresp.getBody() != null)
                {
                    System.Debug('****** raw b Response: ' + bresp.getBody());
                    bretVal = (Map<String, Object>) JSON.deserializeUntyped(bresp.getBody());
                    System.Debug('****** bretVal: ' + bretVal.size());
                    System.Debug('****** bretVal: ' + bretVal);
                }
                
                if(!bretVal.isEmpty())
                    aretVal.putAll(bretVal);


putAll(sobjectArray)
Adds the list of sObject records to a map declared as Map<ID, sObject> or Map<String, sObject>.
Hi, 
I'm very new to APEX so please bear with me.  I have 2 different map strings objects and I'm trying to concatenate them using the map method .putAll, however it's replacing instead of concatenating.   

if(aresp.getBody() != null ||  bresp.getBody() != null ){
                Map<String, Object> aretVal;
                Map<String, Object> bretVal;
                if(aresp.getBody() != null)
                {
                    System.Debug('****** raw a Response: ' + aresp.getBody());
                    aretVal = (Map<String, Object>) JSON.deserializeUntyped(aresp.getBody());
                }
                System.Debug('****** aretVal: ' + aretVal.size());
                System.Debug('****** aretVal: ' + aretVal);
                if(bresp.getBody() != null)
                {
                    System.Debug('****** raw b Response: ' + bresp.getBody());
                    bretVal = (Map<String, Object>) JSON.deserializeUntyped(bresp.getBody());
                    System.Debug('****** bretVal: ' + bretVal.size());
                    System.Debug('****** bretVal: ' + bretVal);
                }
                
                if(!bretVal.isEmpty())
                    aretVal.putAll(bretVal);


putAll(sobjectArray)
Adds the list of sObject records to a map declared as Map<ID, sObject> or Map<String, sObject>.