You need to sign in to do that
Don't have an account?

Apex controller Attempt to de-reference a null object error!
Hi,
We've implemented an API that connects to an external database, which we can search within our Salesforce org. I'm running into an
Attempt to de-reference a null object error:

Here is the Visualforce Page:
And the Controller:
How would I resolve this error?
ANY help is MUCH appreciated!
Many Thanks,
Natasha :)
We've implemented an API that connects to an external database, which we can search within our Salesforce org. I'm running into an
Attempt to de-reference a null object error:
Here is the Visualforce Page:
<apex:page controller="EDSSearchController"> <apex:form > <apex:pageBlock title="EDS Search"> Enter search term here: <apex:inputText value="{!searchTerm}"/> <apex:commandButton action="{!Search}" value="Search"/> </apex:pageBlock> </apex:form> </apex:page>
And the Controller:
public class EDSSearchController { public String searchTerm { get; set; } servicesEdrsEducationGovUkV17.EmployerLookupSoap a; EDS_Credentials__c edsCreds; public EDSSearchController() { edsCreds = EDS_Credentials__c.getValues('Default'); a = new servicesEdrsEducationGovUkV17.EmployerLookupSoap(); } public String getSearchTerm() { return searchTerm; } public PageReference search() { a.ByFreeText(searchTerm, false,'O','',edsCreds.API_Key__c); return null; } }
How would I resolve this error?
ANY help is MUCH appreciated!
Many Thanks,
Natasha :)
Hi natasha,
You can setup the debug log for the current user and write some debug statements in the class like
and then check your debug log for the values of these variables. You sould also initialize you search variable with blank string in the constructor.
I hope it helps.
Greetings to you!
- Replace this
<apex:commandButton action="{!Search}" value="Search"/>
- From this
<apex:commandButton action="{!search}" value="Search"/>
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com
Thanks for your response.I tried it but I'm still getting the following error:
Thanks!