You need to sign in to do that
Don't have an account?
Ab
null pointer exception for a map
Hello,
I am getting a null pointer exception in below code.
how can i put a check on below code to check if it is null or not
I am getting a null pointer exception in below code.
how can i put a check on below code to check if it is null or not
public static Map<String, Map<Id, RecordType>> rtTemp = new Map<String, Map<Id, RecordType>>(), public SObjectType oName; public static final String RT_ID = 'rtTemp'; public void setSObjectType(SObjectType objT) { this.oName = objT; } function() { Map<Id, RecordType> rtMap = rtTemp.get(String.valueOf(Account.SObjectType)); String rtTemp = (String) obj.get(RT_ID); String rtDName = rtMap.get(rtTemp).DeveloperName; // Null pointer exception }thank you for suggestion
Greetings!
You can either check for the size of the variable or list which you suspect is returning as null before executing the code or use exception handling as suggested here.
https://help.salesforce.com/articleView?id=000327918&type=1&mode=1
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
All Answers
Greetings!
You can either check for the size of the variable or list which you suspect is returning as null before executing the code or use exception handling as suggested here.
https://help.salesforce.com/articleView?id=000327918&type=1&mode=1
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri