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
Micky MMicky M 

Null value

Hi all im trying to test if the value coming back from a map is null, the key to my map is a string and the value is a list of object, when this bit of code runs :

for(String key : finalFlexBanding.KeySet())
{
  MCS_Opportunity_RS_Line_Item_Import__c l = finalFlexBanding.get(key);

  Decimal minValue = minValues.get(Key);
  System.debug('flex processing bit : minValue = ' + minValue);

  if(minValue == null)
   minValue = 0;

  Opportunity_Recurring_Service_Breakdown__c tempBreakdown = new Opportunity_Recurring_Service_Breakdown__c(Break_Down_Type__c = l.Minimum_or_Flexible__c == 'M' ? 'Minimum Commit' : l.Minimum_or_Flexible__c == 'F' ? 'Flexible' : 'Range', Start_Quantity__c = minValue, End_Quantity__c = l.Quantity__c, Group_Number__c = l.Grouping__c, Metric__c = l.Charging_Metric__c, Unit_Sell_Price__c = l.Unit_Sell_Price__c);
 
  //add it to the map based on grouping
  System.debug('breakdownMap before null test = ' + breakdownMap);
  List<Opportunity_Recurring_Service_Breakdown__c> test = test = breakdownMap.get(Key);

  System.debug('IS TEST NULL? = ' + test);

  if(test == null)
  {
   System.debug('In the null bit ...... ');
   breakdownMap.put(key, new list<Opportunity_Recurring_Service_Breakdown__c>());
  }
  breakdownMap.get(Key).add(tempBreakdown); 
}

if wont go into the condition if(test == null), i have noticed in the debug logs is says the value is (null) rather than null, i dont know if that means anything. Does anyone know whats going on here? Thanks!!!
KevinPKevinP
try testing for a list.size() > 0