You need to sign in to do that
Don't have an account?
Afrose Ahamed
caused by: System.NullPointerException: Argument cannot be null.
Hi All,
At line 13 im getting error System.NullPointerException: Argument cannot be null. Please help me guys how can i sort out this issue
Error Line Highlighted in Bold
public with sharing class checkRec{ public List<sObject> soblist {get;set;} public String oblabel { get;set;} public String Obtype {get;set;} //Object API Name public List<Schema.FieldSetMember> fls {get;set;} //The fields from the fieldset public String obql {get;set;} public Search__c Search {get;set;} public String spquery { get;set; } public String spqueryid { get;set; } public checkRec(){ //set Object Type and Fields(Error Line) evt= String.escapeSingleQuotes(ApexPages.currentPage().getParameters().get('Obtype ')); if(Obtype == getNamePrefix.getNamePrefix()+'Check__c') Obtype = getNamePrefix.getNamePrefix()+'Note__c'; if(Obtype == getNamePrefix.getNamePrefix()+'Source__c') Obtype = getNamePrefix.getNamePrefix()+'Data_Source__c'; if(Obtype == getNamePrefix.getNamePrefix()+'User_Details__C') Obtype = 'User'; Map<String , Schema.SObjectType> globalDescription = Schema.getGlobalDescribe(); oblabel= globalDescription.get(Obtype ).getDescribe().getLabel(); Schema.SObjectType SObjectTypeObj = globalDescription.get(Obtype); Schema.DescribeSObjectResult DescribeSObjectResultObj = SObjectTypeObj.getDescribe(); try{ Schema.FieldSet fieldSetObj = DescribeSObjectResultObj.FieldSets.getMap().get(getNamePrefix.getNamePrefix()+'LookUp'); fields = fieldSetObj.getFields(); } catch(exception e){ System.debug('Add Loos Field Set to this object'); ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'This Object does not have a \'checkRec\' Field Set')); } Search__c = new Search__c(); runlooks(); }
Thanks,
Afrose Ahamed M.G.
Reason behind:- You are not Passing parameter "Obtype" in URL because of that it's give you error.
To handle this write if condition to check null value of that parameter.
see below updated class code.
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
All Answers
Reason behind:- You are not Passing parameter "Obtype" in URL because of that it's give you error.
To handle this write if condition to check null value of that parameter.
see below updated class code.
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Hi @mukesh gupta,
Thanks for you reply,
Yes, I added the line. However when im clicking the preview its im getting the same error. Is possible to add return null in constructor. I Hope we cannot add return null in constructor. Please advise.
Thanks in advance.
Afrose
Don't test by preview button, just go to actual record and check
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh