You need to sign in to do that
Don't have an account?
Sudhir_Meru
Not able to Store Lookup Value to Custom Object from Visualforce Page to Controller
Hi,
Created a controler as mentioned below
Class
public with sharing class storelookup{
public Asset GetReseller{get;set;}
public void processSelected() {
SUDHIR__c TempAssetList = new SUDHIR__c();
TempAssetList.test__c = GetReseller.AccountId;
Insert TempAssetList;
}
}
Visual Force Page
<apex:page Controller="storelookup">
<apex:form >
<apex:pageBlock >
<apex:inputField value="{!GetReseller.AccountId}"/>
<apex:pageBlockButtons >
<apex:commandButton value="Save Records" action="{!processSelected}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
I am getting below error message please suggest me how to fix
Visualforce Error
Help for this Page
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!processSelected}' in component <apex:commandButton> in page storelookup
Class.storelookup.processSelected: line 9, column 1
Created a controler as mentioned below
Class
public with sharing class storelookup{
public Asset GetReseller{get;set;}
public void processSelected() {
SUDHIR__c TempAssetList = new SUDHIR__c();
TempAssetList.test__c = GetReseller.AccountId;
Insert TempAssetList;
}
}
Visual Force Page
<apex:page Controller="storelookup">
<apex:form >
<apex:pageBlock >
<apex:inputField value="{!GetReseller.AccountId}"/>
<apex:pageBlockButtons >
<apex:commandButton value="Save Records" action="{!processSelected}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
I am getting below error message please suggest me how to fix
Visualforce Error
Help for this Page
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!processSelected}' in component <apex:commandButton> in page storelookup
Class.storelookup.processSelected: line 9, column 1
You are getting NPE due to "GetReseller" is not initilize with any value.
You might have to create new instance of Assets or fetch existing Assets from database. Below is sample constructor for your reference.
public storelookup(){
GetReseller = new Asset();
// GetReseller = [select id, AccountId from Asset where ...]
}
Hope this will solve your problem.
All Answers
You are getting NPE due to "GetReseller" is not initilize with any value.
You might have to create new instance of Assets or fetch existing Assets from database. Below is sample constructor for your reference.
public storelookup(){
GetReseller = new Asset();
// GetReseller = [select id, AccountId from Asset where ...]
}
Hope this will solve your problem.
try below code..
[If it helps, mark it as "Best Answer"]
Thanks,
Rockzz