Skip to main content
replaced http://salesforce.stackexchange.com/ with https://salesforce.stackexchange.com/
Source Link

My question is continuation of what I have asked herehere

How do I replace from:

parentChildCase.get(cMap.get(c).ID).add(cMap.get(c));

to this Id (pId):

Map<id, id> par = new Map<id, id>();  

List <case> rcases =[SELECT ... FROM CASE WHERE <other_conditions....>];
for (case c : rcases) {
  par.put(c.id,c.ParentId);
}

Id = pId = par.get(cMap.get(c).Parentid); 

Error NullPointerException: Attempt to de-Reference a null object

for(ID c : cMap.keySet()) 
{
    if(parentChildCase.containsKey(cMap.get(c).ID)) 
    {
        //parentChildCase.get(cMap.get(c).ID).add(cMap.get(c));
        Id pId = par.get(cMap.get(c).Parentid);
        parentChildCase.get(pId).add(cMap.get(c)); //ERROR      NullPointerException: Attempt to de-Reference a null object
    }
    else
    {
        List<Case> cases = new List<Case>();
        cases.add(cMap.get(c));
        parentChildCase.put(cMap.get(c).ID, cases);
    }
}

My question is continuation of what I have asked here

How do I replace from:

parentChildCase.get(cMap.get(c).ID).add(cMap.get(c));

to this Id (pId):

Map<id, id> par = new Map<id, id>();  

List <case> rcases =[SELECT ... FROM CASE WHERE <other_conditions....>];
for (case c : rcases) {
  par.put(c.id,c.ParentId);
}

Id = pId = par.get(cMap.get(c).Parentid); 

Error NullPointerException: Attempt to de-Reference a null object

for(ID c : cMap.keySet()) 
{
    if(parentChildCase.containsKey(cMap.get(c).ID)) 
    {
        //parentChildCase.get(cMap.get(c).ID).add(cMap.get(c));
        Id pId = par.get(cMap.get(c).Parentid);
        parentChildCase.get(pId).add(cMap.get(c)); //ERROR      NullPointerException: Attempt to de-Reference a null object
    }
    else
    {
        List<Case> cases = new List<Case>();
        cases.add(cMap.get(c));
        parentChildCase.put(cMap.get(c).ID, cases);
    }
}

My question is continuation of what I have asked here

How do I replace from:

parentChildCase.get(cMap.get(c).ID).add(cMap.get(c));

to this Id (pId):

Map<id, id> par = new Map<id, id>();  

List <case> rcases =[SELECT ... FROM CASE WHERE <other_conditions....>];
for (case c : rcases) {
  par.put(c.id,c.ParentId);
}

Id = pId = par.get(cMap.get(c).Parentid); 

Error NullPointerException: Attempt to de-Reference a null object

for(ID c : cMap.keySet()) 
{
    if(parentChildCase.containsKey(cMap.get(c).ID)) 
    {
        //parentChildCase.get(cMap.get(c).ID).add(cMap.get(c));
        Id pId = par.get(cMap.get(c).Parentid);
        parentChildCase.get(pId).add(cMap.get(c)); //ERROR      NullPointerException: Attempt to de-Reference a null object
    }
    else
    {
        List<Case> cases = new List<Case>();
        cases.add(cMap.get(c));
        parentChildCase.put(cMap.get(c).ID, cases);
    }
}
Source Link
Nick
  • 7.2k
  • 27
  • 147
  • 286

Parent/Child on same Case object : NullPointerException: Attempt to de-Reference a null object

My question is continuation of what I have asked here

How do I replace from:

parentChildCase.get(cMap.get(c).ID).add(cMap.get(c));

to this Id (pId):

Map<id, id> par = new Map<id, id>();  

List <case> rcases =[SELECT ... FROM CASE WHERE <other_conditions....>];
for (case c : rcases) {
  par.put(c.id,c.ParentId);
}

Id = pId = par.get(cMap.get(c).Parentid); 

Error NullPointerException: Attempt to de-Reference a null object

for(ID c : cMap.keySet()) 
{
    if(parentChildCase.containsKey(cMap.get(c).ID)) 
    {
        //parentChildCase.get(cMap.get(c).ID).add(cMap.get(c));
        Id pId = par.get(cMap.get(c).Parentid);
        parentChildCase.get(pId).add(cMap.get(c)); //ERROR      NullPointerException: Attempt to de-Reference a null object
    }
    else
    {
        List<Case> cases = new List<Case>();
        cases.add(cMap.get(c));
        parentChildCase.put(cMap.get(c).ID, cases);
    }
}