You need to sign in to do that
Don't have an account?
shashi kanaparthi
Updating values of Apex Input not being reflected in database up on save
Hi,
I am working on a requirement where once the user clicks on a button, it opens up a form known as "ISR Form". When the form opens up, the form should show previously entered input values, i am able to achieve this. But when the user changes the input value in "Number of Drug Libraries", then the value is not being updated in the database. Below is the code for the VF Page and the controller class. Let me know what the issue could be?
VF Page Code:
<apex:page standardController="ISR__c" extensions="ISRFormController" sidebar="false" language="en-US" >
<Apex:form onreset="false">
<apex:pageBlock mode="edit" title="ISR Edit" id="pb">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Save}"/>
<apex:commandButton value="Export To Excel"/>
<apex:commandButton value="Cancel" action="{!Cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="General Information" columns="2" >
<apex:repeat var="opp" value="{!opplst}" >
<apex:pageBlockSectionitem >
<apex:outputText value="Implementation Type "/>
<apex:outputText value="{!opp.Implementation_Type__c}" style="background-color:#F4F6F6;"/>
</apex:pageBlockSectionitem>
<apex:pageBlockSectionitem >
<apex:outputText value="Contract Signed "/>
<apex:outputField value="{!opp.Contract_Signed__c}" style="background-color:#F4F6F6;"/>
</apex:pageBlockSectionitem>
<apex:inputText value="{!ISR.Number_of_Drug_Libraries__c}"/>
<apex:inputfield value="{!ISR.Integration_Partner__c}"/>
</apex:form>
Controller Class:-
public class ISRFormController {
public Opportunity opp{get;set;}
public ISRFormController(ApexPages.StandardController controller) {
ISRSales = new ISR_Sales_Team__c ();
opporid= ApexPages.currentPage().getParameters().get('oppid');
Accid=ApexPages.currentPage().getParameters().get('accountid');
ISRId=ApexPages.currentPage().getParameters().get('ISRId');
}
public ISR__c ISR{
get{
if(ISRId!=null)
//ISR=new ISR__c();
ISR=[Select Id,Number_of_Drug_Libraries__c,Integration_Partner__c,Other__c,Comments__c,Address__c,Nearest_Airport__c,Nearest_Hotel_Area__c,
Amount_of_Integrated_Implementation_Fees__c,Does_contract_include_Data_Analytics_Ser__c,customer_ACA_language_contract__c,
Vendor_Credentialing__c,customer_using_Third_Party_Financ__c,contract_signed_for_third__c,Customer_USing_UHS__c,
If_yes_have_the_devices_been_ordered__c,Rental_Program__c,Did_the_customer_participate_in_a_MedNet__c,
If_yes_please_indicate_device_type__c,If_Yes_please_indicate_MM_YYYY__c,
Other_Comments__c,Form_Completed_by__c,Date__c,Implementation_Model__c,Project_Manager__c,Hospira_Pharmacy_Consultant__c,
RNE_Regional_Nurse_Executive__c,CC_Designated_Lead__c,Email_Received_from_DM_Date__c,Project_Back_to_Sales_Date__c,
Data_Entered_In_By_Virtual_Server_IT_Tea__c,Customer_Log_in__c,Customer_Password__c,Data_Entered_In_By_Portal_Admin_Team__c,
ACA_Service_Login__c,ACA_Service_Password__c,Target_Go_Live_Date__c
from ISR__c where Id=:ISRId];
return ISR;
}
set;}
public PageReference Save(){
if(ISRId==null){
insert ISR;
}
if(ISRId!=null){
update ISR;
}
}
I am working on a requirement where once the user clicks on a button, it opens up a form known as "ISR Form". When the form opens up, the form should show previously entered input values, i am able to achieve this. But when the user changes the input value in "Number of Drug Libraries", then the value is not being updated in the database. Below is the code for the VF Page and the controller class. Let me know what the issue could be?
VF Page Code:
<apex:page standardController="ISR__c" extensions="ISRFormController" sidebar="false" language="en-US" >
<Apex:form onreset="false">
<apex:pageBlock mode="edit" title="ISR Edit" id="pb">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Save}"/>
<apex:commandButton value="Export To Excel"/>
<apex:commandButton value="Cancel" action="{!Cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="General Information" columns="2" >
<apex:repeat var="opp" value="{!opplst}" >
<apex:pageBlockSectionitem >
<apex:outputText value="Implementation Type "/>
<apex:outputText value="{!opp.Implementation_Type__c}" style="background-color:#F4F6F6;"/>
</apex:pageBlockSectionitem>
<apex:pageBlockSectionitem >
<apex:outputText value="Contract Signed "/>
<apex:outputField value="{!opp.Contract_Signed__c}" style="background-color:#F4F6F6;"/>
</apex:pageBlockSectionitem>
<apex:inputText value="{!ISR.Number_of_Drug_Libraries__c}"/>
<apex:inputfield value="{!ISR.Integration_Partner__c}"/>
</apex:form>
Controller Class:-
public class ISRFormController {
public Opportunity opp{get;set;}
public ISRFormController(ApexPages.StandardController controller) {
ISRSales = new ISR_Sales_Team__c ();
opporid= ApexPages.currentPage().getParameters().get('oppid');
Accid=ApexPages.currentPage().getParameters().get('accountid');
ISRId=ApexPages.currentPage().getParameters().get('ISRId');
}
public ISR__c ISR{
get{
if(ISRId!=null)
//ISR=new ISR__c();
ISR=[Select Id,Number_of_Drug_Libraries__c,Integration_Partner__c,Other__c,Comments__c,Address__c,Nearest_Airport__c,Nearest_Hotel_Area__c,
Amount_of_Integrated_Implementation_Fees__c,Does_contract_include_Data_Analytics_Ser__c,customer_ACA_language_contract__c,
Vendor_Credentialing__c,customer_using_Third_Party_Financ__c,contract_signed_for_third__c,Customer_USing_UHS__c,
If_yes_have_the_devices_been_ordered__c,Rental_Program__c,Did_the_customer_participate_in_a_MedNet__c,
If_yes_please_indicate_device_type__c,If_Yes_please_indicate_MM_YYYY__c,
Other_Comments__c,Form_Completed_by__c,Date__c,Implementation_Model__c,Project_Manager__c,Hospira_Pharmacy_Consultant__c,
RNE_Regional_Nurse_Executive__c,CC_Designated_Lead__c,Email_Received_from_DM_Date__c,Project_Back_to_Sales_Date__c,
Data_Entered_In_By_Virtual_Server_IT_Tea__c,Customer_Log_in__c,Customer_Password__c,Data_Entered_In_By_Portal_Admin_Team__c,
ACA_Service_Login__c,ACA_Service_Password__c,Target_Go_Live_Date__c
from ISR__c where Id=:ISRId];
return ISR;
}
set;}
public PageReference Save(){
if(ISRId==null){
insert ISR;
}
if(ISRId!=null){
update ISR;
}
}
Your code wouldn't compile, so I presume something's missing, but your save method could be: Or try this:
Please mark this post as solved if it helps.
Best Regards,
Nagendra.P