You need to sign in to do that
Don't have an account?
vamshi Cap
Apex script unhandled exception by user/organization:
What is mean by this error: how can I handle. we already doing null checking,
For example:
Apex script unhandled exception by user/organization: 00*************TE/00************gRb4
Visualforce Page: /apex/ppaccountsummary
caused by: System.NullPointerException: Attempt to de-reference a null object
Class.PPOrdersController.<init>: line 17, column 1
* @description - Utility class for validation of empty values, number, length , date etc.
*/
global with sharing class Util {
/**
* @author - Shatanik
* @date - 10/29/2012
* @description -This method Copies field values from source object to destination Object.
* @param sourceObj- SObject.
* @param destinationObj- SObject
*/
global static void copyFieldsFromSourceToDestinationObj(SObject sourceObj, SObject destinationObj){
System.debug('In copyFieldsFromSourceToDestinationObj --------------->>>');
if(sourceObj != null && destinationObj != null){
Set<String> destinationFieldSet = new Set<String>();
String sourceObjName = sourceObj.getsObjectType().getDescribe().getLocalName();
String destinationObjName = destinationObj.getsObjectType().getDescribe().getLocalName();
System.debug('sourceObjName --------------->>>'+sourceObjName);
System.debug('destinationObjName --------------->>>'+destinationObjName);
Map<String, Schema.DescribeFieldResult> sourceObjFieldDescMap = DescribeCachingUtility.getFieldDescribe(sourceObjName);
System.debug('sourceObjFieldDescMap --------------->>>'+sourceObjFieldDescMap);
Map<String, Schema.DescribeFieldResult> destinationObjFieldDescMap = DescribeCachingUtility.getFieldDescribe(destinationObjName);
System.debug('destinationObjFieldDescMap --------------->>>'+destinationObjFieldDescMap);
for(Schema.DescribeFieldResult destfieldResult : destinationObjFieldDescMap.Values()){
if(destfieldResult.isUpdateable()){
destinationFieldSet.add(destfieldResult.getLocalName());
}else if(String.valueOf(destfieldResult.getType()).equalsIgnoreCase('REFERENCE') && destfieldResult.isPermissionable()){
destinationFieldSet.add(destfieldResult.getLocalName());
}
}
System.debug('destinationFieldSet ---------------------------->>>>'+destinationFieldSet);
for(Schema.DescribeFieldResult sourceField : sourceObjFieldDescMap.Values()){
String localName = sourceField.getLocalName();
System.debug('sourceField======================' + sourceField);
String dataType = sourceField.getType().name();
// Compare the localname of the field with the names of the fields in the above created account order set
// If they match then copy over the value of the field from C30 Account to Account Order
if(destinationFieldSet.contains(localName)){
if(sourceObj.get(localName) != null){
destinationObj.put(localName, sourceObj.get(localName));
}else if(sourceObj.get(localName) == null){
if(dataType.equalsIgnoreCase('TEXTAREA') || dataType.equalsIgnoreCase('String') || dataType.equalsIgnoreCase('Phone') || dataType.equalsIgnoreCase('Integer') || dataType.equalsIgnoreCase('Double')){
destinationObj.put(localName, null);
}
}
}
}
}
System.debug('sourceObj ---------------------------->>>>'+sourceObj);
System.debug('destinationObj ---------------------------->>>>'+destinationObj);
}
/**************************************************************************************************************************/
/**
* @description - Checks the passed in input field for emptyness and return boolean value.
*
* @param fldName - name of the field
* @param msg - message to be displayed on UI (can be select/enter)
* @param value - value of input field
*/
global static boolean isEmpty(String value){
boolean flag = false;
if(value == null || value.trim().equals(Cycle30Constants.BLANK)){
flag = true;
}
return flag;
}
/**
* @author Tohar Patel
* @description Check whether list is empty
* @param ex Exception which is printed in system log
* @return Boolean True if String is empty or null else return false
*/
global static boolean isEmpty(List<SObject> objList) {
if(objList == null || objList.size()==0) {
return true;
}else {
return false;
}
}
/**
* @author Neha Gire
* @description Check whether sObject is null
* @param ex Exception which is printed in system log
* @return Boolean True if Sobject is null else return false
*/
global static boolean isEmpty(SObject obj) {
if(obj == null) {
return true;
}else {
return false;
}
}
/**
* @author Tohar Patel
* @description Check whether list is empty
* @param ex Exception which is printed in system log
* @return Boolean True if String is empty or null else return false
*/
global static boolean isEmpty(List<object> objList) {
if(objList == null || objList.size()==0) {
return true;
}else {
return false;
}
}
/**
* @author Tohar Patel
* @date 01/11/2012
* @description - The method returns a random hex code using the 'SHA1' algorithm
*
* @modifiedBy - <Name> : date - <date of change> : purpose - <purpose of change>
* Above line should be added for each change
*/
global static String getRandomHexCode(){
String randomStr = String.valueOf(Integer.valueOf((Math.random()*System.currentTimeMillis())*System.currentTimeMillis()))+ String.valueOf(System.currentTimeMillis());
Blob hash = Crypto.generateDigest(Cycle30Constants.SHA1_ENCRYPTION,Blob.valueOf(randomStr));
String hexDigest = EncodingUtil.convertToHex(hash);
System.debug(hexDigest);
return hexDigest;
}
/**
* @author Monali
* @date 03/18/2013
* @description Check whether map is empty
* @param map<String,Object> map to check whether is empty or not
* @return Boolean True if map is empty or null else return false
*/
global static boolean isEmpty(Map<String,Object> objectMap){
if(objectMap == null || (objectMap != null && objectMap.size()==0)) {
return true;
}else {
return false;
}
}
/**
* @author Monali
* @description Check whether Object is null
* @param object to check whether it is null or not
* @return Boolean True if Object is null else return false
*/
global static boolean isEmpty(Object obj) {
if(obj == null) {
return true;
}else {
return false;
}
}
}
global static boolean isEmpty(String value){
boolean flag = false;
if(value == null || value.trim().equals(Cycle30Constants.BLANK)){
flag = true;
}
return flag;
}
This method is getting called from your class, in if condition, value.trim().equals(Cycle30Constants.BLANK), through the error, because of vaule is a null string
public static final String BLANK = '';
What here I am saying is, the variable value is null, and when you try to call any method, like you called trim, which is throughing error, you can trim a null value. Please pass some accountId value in URL and try again, It should work for sure. I guarantee it.