+ Start a Discussion
RICARDO PALMARICARDO PALMA 

I can't save the lookup field value in a visualforce page

Hi,
I have a custom visualforce page with a lookup field that I want to save.

For some reason it looks like I'm not able to pass the lookup value from the visualforce page to the controller 

VisualForce Page:
<apex:inputField value="{!OpportunityLineItem.FRMS_Customer_Social_Media_Contact_Alt1__c}" >
<apex:param name="alt1" value="{!OpportunityLineItem.FRMS_Customer_Social_Media_Contact_Alt1__c}" assignTo="{!ContactAlt1}"/>
</apex:inputField>

Controller:
public class DisplayingActivationFields {
public id   ContactAlt1{get;set;}
list <OpportunityLineItem> proList = [SELECT Id, Product2id, OpportunityId, Advertiser_Account__c, Fullfillment_Rep__c, Approved_by_FRSocial__c, Rejected_by_FRSocial__c, Rejection_Comment__c, FRMS_Customer_Social_Media_Contact_Alt1__c, FRMS_Customer_Social_Media_Contact_Alt2__c, FRMS_Customer_Social_Media_Contact_Alt3__c FROM OpportunityLineItem  Where id=:ApexPages.currentPage().getParameters().get('id')];

 public displayingactivationfields(ApexPages.StandardController controller) {
    this.oppprorec = (OpportunityLineItem)controller.getRecord();
  }

public void  FetchData() {
some code...
}
public PageReference save(){ 
for (OpportunityLineItem rid :proList){
rid.FRMS_Customer_Social_Media_Contact_Alt1__c = ContactAlt1;
system.debug('&&&&&&&&& '+ ContactAlt1); ContactAlt1 returns NULL all the time after clicking the save buttton.

}
}

update proList;

}

}


 
Gaurish Gopal GoelGaurish Gopal Goel
Hi Ricardo,

You don't actually need <apex:param> tag. You will get your value in "OpportunityLineItem.FRMS_Customer_Social_Media_Contact_Alt1__c". Please remove the param tag and delete the ContactAlt1 variable.
RICARDO PALMARICARDO PALMA
Hi Gaurish, 
I did it, but it didn't work. For some reason isn't saving the value on the lookup field.

 
RICARDO PALMARICARDO PALMA
I got it working Gaurish, 
Adding the following:

private ApexPages.StandardController stdCtrl;
public displayingactivationfields(ApexPages.StandardController controller) {
    stdCtrl=controller;
public PageReference save(){ 
OpportunityLineItem cont=(OpportunityLineItem) stdCtrl.getRecord();
update cont;
}
}

Thanks for your help.
Cheers!