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
sandeep kumar 140sandeep kumar 140 

System.NullPointerException: Argument cannot be null

Hi all,

Below is my code.

If(leadList[0].Sector__c=='Salaried'){
            If(mbd.Score__c >=600 && mbd.Score__c<650){
                leadList[0].Interest_Rate__c = 12.00;
            }else if(mbd.Score__c >=650 && mbd.Score__c<700){
                leadList[0].Interest_Rate__c =11.25;
            }else if(mbd.Score__c>=700 && mbd.Score__c<750){
                leadList[0].Interest_Rate__c = 10.25;
            }else if(mbd.Score__c>=750){
                leadList[0].Interest_Rate__c = 8.25;
            }else if(mbd.Score__c==-1){
                leadList[0].Interest_Rate__c = 12.75;
            }else if(mbd.Score__c==4){
                leadList[0].Interest_Rate__c = 11.25;
            }else if(mbd.Score__c == 5){
                leadList[0].Interest_Rate__c = 11.25;
            } 
        }else if(leadList[0].Sector__c=='SENP' && leadList[0].Sector__c=='SEP'){
            if(mbd.Score__c >=700 && mbd.Score__c<750){
                leadList[0].Interest_Rate__c = 10.25;
            }else if(mbd.Score__c >=750){
                leadList[0].Interest_Rate__c = 9.25;
            }else if(mbd.Score__c==4){
                leadList[0].Interest_Rate__c = 12.00;
            }else if(mbd.Score__c==5){
                leadList[0].Interest_Rate__c = 12.00;
            }
        }              
    }
    // Calculating Proposed EMI
 leadList[0].Proposed_EMI__c = (leadList[0].Amount_in_Rs__c+(leadList[0].Amount_in_Rs__c*leadList[0].Interest_Rate__c*leadList[0].Loan_Tenor_in_Month__c)/12)/leadList[0].Loan_Tenor_in_Month__c;
    system.debug('proposed emi--'+leadList[0].Proposed_EMI__c);

At Proposed EMI am getting Zero(0) even i have all the field values. What is the problem please let me know.

Thanks
Prem Anandh 1Prem Anandh 1
Hi Sandeep, 

Please add one more condition before If(leadList[0].Sector__c=='Salaried').  
If(!leadList.isEmpty())
{
If()
{
}
else if
{
}
.
.
.
}


 
Shaijan ThomasShaijan Thomas
print the below values before calculation
system.debug('leadList[0].Proposed_EMI__c : '+leadList[0].Proposed_EMI__c);
system.debug('leadList[0].Amount_in_Rs__c : '+leadList[0].Amount_in_Rs__c);
system.debug('leadList[0].Interest_Rate__c : '+leadList[0].Interest_Rate__c);
system.debug('leadList[0].Loan_Tenor_in_Month__c : '+leadList[0].Loan_Tenor_in_Month__c);

once you get the values use calculator to calculate
Thanks
Prem Anandh 1Prem Anandh 1
What is the exact issue? As per my understanding its Null pointer exception. Can you please elaborate this?
mayurmayur
You are tring to get value from empty list. use below code:
if(!leadList.isEmpty()){
	If(leadList[0].Sector__c=='Salaried'){
	If(mbd.Score__c >=600 && mbd.Score__c<650){
		leadList[0].Interest_Rate__c = 12.00;
	}else if(mbd.Score__c >=650 && mbd.Score__c<700){
		leadList[0].Interest_Rate__c =11.25;
	}else if(mbd.Score__c>=700 && mbd.Score__c<750){
		leadList[0].Interest_Rate__c = 10.25;
	}else if(mbd.Score__c>=750){
		leadList[0].Interest_Rate__c = 8.25;
	}else if(mbd.Score__c==-1){
		leadList[0].Interest_Rate__c = 12.75;
	}else if(mbd.Score__c==4){
		leadList[0].Interest_Rate__c = 11.25;
	}else if(mbd.Score__c == 5){
		leadList[0].Interest_Rate__c = 11.25;
	} 
}
else if(leadList[0].Sector__c=='SENP' && leadList[0].Sector__c=='SEP'){
	if(mbd.Score__c >=700 && mbd.Score__c<750){
		leadList[0].Interest_Rate__c = 10.25;
	}else if(mbd.Score__c >=750){
		leadList[0].Interest_Rate__c = 9.25;
	}else if(mbd.Score__c==4){
		leadList[0].Interest_Rate__c = 12.00;
	}else if(mbd.Score__c==5){
		leadList[0].Interest_Rate__c = 12.00;
	}
}              

    // Calculating Proposed EMI
 leadList[0].Proposed_EMI__c = (leadList[0].Amount_in_Rs__c+(leadList[0].Amount_in_Rs__c*leadList[0].Interest_Rate__c*leadList[0].Loan_Tenor_in_Month__c)/12)/leadList[0].Loan_Tenor_in_Month__c;
 system.debug('proposed emi--'+leadList[0].Proposed_EMI__c);
}


 
VIVEK 998VIVEK 998
Hi Sandeep,
You are accesing the list which is either not instantiated or must have been querying zero records.
So for instance you can put both the conditions check :

if(leadList != null && !leadList.isEmpty()){
    If(leadList[0].Sector__c=='Salaried'){
    If(mbd.Score__c >=600 && mbd.Score__c<650){
        leadList[0].Interest_Rate__c = 12.00;
    }else if(mbd.Score__c >=650 && mbd.Score__c<700){
        leadList[0].Interest_Rate__c =11.25;
    }else if(mbd.Score__c>=700 && mbd.Score__c<750){
        leadList[0].Interest_Rate__c = 10.25;
    }else if(mbd.Score__c>=750){
        leadList[0].Interest_Rate__c = 8.25;
    }else if(mbd.Score__c==-1){
        leadList[0].Interest_Rate__c = 12.75;
    }else if(mbd.Score__c==4){
        leadList[0].Interest_Rate__c = 11.25;
    }else if(mbd.Score__c == 5){
        leadList[0].Interest_Rate__c = 11.25;
    } 
}
else if(leadList[0].Sector__c=='SENP' && leadList[0].Sector__c=='SEP'){
    if(mbd.Score__c >=700 && mbd.Score__c<750){
        leadList[0].Interest_Rate__c = 10.25;
    }else if(mbd.Score__c >=750){
        leadList[0].Interest_Rate__c = 9.25;
    }else if(mbd.Score__c==4){
        leadList[0].Interest_Rate__c = 12.00;
    }else if(mbd.Score__c==5){
        leadList[0].Interest_Rate__c = 12.00;
    }
}              

    // Calculating Proposed EMI
 leadList[0].Proposed_EMI__c = (leadList[0].Amount_in_Rs__c+(leadList[0].Amount_in_Rs__c*leadList[0].Interest_Rate__c*leadList[0].Loan_Tenor_in_Month__c)/12)/leadList[0].Loan_Tenor_in_Month__c;
 system.debug('proposed emi--'+leadList[0].Proposed_EMI__c);
}


Mark as answer if you find correct.
Thanks!
sandeep kumar 140sandeep kumar 140
Hi all,

I have tried the same but facing same issue. Below is my code.

list<Contact> conList = [select id,Lead__r.LeadSource_S__c,FirstName,LastName,Lead__c,Birthdate,Age1__c,Gender__c,PAN_ID__c,Lead__r.Sector__c,Lead__r.Proposed_EMI__c,Lead__r.Amount_in_Rs__c,Lead__r.Interest_Rate__c,Lead__r.Loan_Tenor_in_Month__c,Lead__r.FOIR__c,Lead__r.Existing_EMI__c,Lead__r.Net_Salary_Monthly__c,OtherStreet,OtherCity,OtherPostalCode,OtherState,OtherCountry,mailingStreet, mailingState, mailingPostalCode,mailingCountry,mailingCity from contact where id in: trigger.newmap.keyset()];
    //system.debug('list'+conList);
    Multibureau_Data__c mbd = [select id, Name, Score__c,Contact__c from Multibureau_Data__c where Contact__c=:conList[0].id];
    //system.debug('data---'+mbd);
    //Loop through all records in the Trigger.newmap collection   
    for(contact con : conList ){
        if(con.Lead__r.LeadSource_S__c  == IndiaLendsLS ){
            rid = con.id ; 
            //Instantiate Class
            // MultibureauRequest mr = new  MultibureauRequest();
            // mr.m1(rid);
            // CIBILConnection C1 = new CIBILConnection(); // instantiate Class
            CIBILConnection.CIBILConnection(rid);
        }
        // Calculating Interest Rate Based on Sector and Score                 
        If(con.Lead__r.Sector__c=='Salaried'){
            If(mbd.Score__c >=600 && mbd.Score__c<650){
                con.Lead__r.Interest_Rate__c = 12.00;
            }else if(mbd.Score__c >=650 && mbd.Score__c<700){
                con.Lead__r.Interest_Rate__c =11.25;
            }else if(mbd.Score__c>=700 && mbd.Score__c<750){
                con.Lead__r.Interest_Rate__c = 10.25;
            }else if(mbd.Score__c>=750){
                con.Lead__r.Interest_Rate__c = 8.25;
            }else if(mbd.Score__c==-1){
                con.Lead__r.Interest_Rate__c = 12.75;
            }else if(mbd.Score__c==4){
                con.Lead__r.Interest_Rate__c = 11.25;
            }else if(mbd.Score__c == 5){
                con.Lead__r.Interest_Rate__c = 11.25;
            } 
        }else if(con.Lead__r.Sector__c=='SENP' && con.Lead__r.Sector__c=='SEP'){
            if(mbd.Score__c >=700 && mbd.Score__c<750){
                con.Lead__r.Interest_Rate__c = 10.25;
            }else if(mbd.Score__c >=750){
                con.Lead__r.Interest_Rate__c = 9.25;
            }else if(mbd.Score__c==4){
                con.Lead__r.Interest_Rate__c = 12.00;
            }else if(mbd.Score__c==5){
                con.Lead__r.Interest_Rate__c = 12.00;
            }
          conList.add(con);  
        }        
      }
    //  update conList;                    
    // Calculating Proposed EMI
    conList[0].Lead__r.Proposed_EMI__c = (conList[0].Lead__r.Amount_in_Rs__c+(conList[0].Lead__r.Amount_in_Rs__c*conList[0].Lead__r.Interest_Rate__c*conList[0].Lead__r.Loan_Tenor_in_Month__c)/12)/conList[0].Lead__r.Loan_Tenor_in_Month__c;
    system.debug('proposed emi--'+conList[0].Lead__r.Proposed_EMI__c);

please check and tell me the issue....
System.NullPointerException: Argument cannot be null
 
VIVEK 998VIVEK 998
Can you repost your full code as on which trigger event it's firing and also which line is showing error.?
sandeep kumar 140sandeep kumar 140
Hi all,

Thanks for your reply.. Issue has resloved. Now i want to update the some fields(Credit Decision,Interest Rate,FOIR) on lead. How to do that. Please let me know.

Thanks in advance.