I have created controller and vf page.In my controller having three buttons such as modify,save and cancel.when i click the modify button(read only) it display the same page with save and cancel button.when i select the picklist value it will be updated in account object.when i click the save button i am getting this error ;
System.QueryException: List has no rows for assignment to SObject Error is in expression '{!Submit}' in component in page rfleet_paymetcondition: Class.Rfleet_PaymentConditions.Submit: line 38, column 1.
How can i resolve this issue. please find below attached images controller and vf page
Vf Page:
<apex:page standardController="account" extensions="Rfleet_PaymentConditions" showHeader="false" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons location="bottom" >
<apex:commandbutton value="Modify" action="{!save}" rendered="{!showSave}" />
<apex:commandbutton value="Save" action="{!Submit}" rendered="{!showSubmit}"/>
<apex:commandbutton value="Cancel" action="{!Back}" rendered="{!showback}"/>
</apex:pageBlockButtons>
<apex:panelGrid columns="2" width="100%" html-readonly="true">
<!-------------------- Start Period1 Section---------------------------------------->
<apex:pageblock title="Period 1" id="blockA" >
<apex:outputPanel id="otpn">
<apex:outputLabel ><b>Upper Date </b></apex:outputLabel>
<apex:inputField value="{!acc.Rfleet_UpperDate_Period1__c}" html-disabled="{!bool}" id="acctype"/>
<script>document.getElementById('{!$Component.acctype}').disabled = {!bool}; </script>
<apex:inputField value="{!account.Rfleet_UpperMonth_Period1__c}" html-disabled="{!bool}" id="acctype1"/><br/><br/>
<script>document.getElementById('{!$Component.acctype1}').disabled = {!bool}; </script>
<apex:outputLabel ><b>Lower Date </b></apex:outputLabel>
<apex:inputField value="{!account.Rfleet_LowerDate_Period1__c}" html-disabled="{!bool}" id="acctype2"/>
<script>document.getElementById('{!$Component.acctype2}').disabled = {!bool}; </script>
<apex:inputField value="{!account.Rfleet_LowerMonth_Period1__c}" html-disabled="{!bool}" id="acctype3"/><br/><br/>
<script>document.getElementById('{!$Component.acctype3}').disabled = {!bool}; </script>
<apex:outputLabel ><b>Due Date </b></apex:outputLabel>
<apex:inputField value="{!account.Rfleet_DueDate_Period1__c}" html-disabled="{!bool}" id="acctype4"/>
<script>document.getElementById('{!$Component.acctype4}').disabled = {!bool}; </script>
<apex:inputField value="{!account.Rfleet_DueMonth_Period1__c}" html-disabled="{!bool}" id="acctype5"/>
<script>document.getElementById('{!$Component.acctype5}').disabled = {!bool}; </script>
</apex:outputPanel>
</apex:pageBlock>
<apex:pageblock title="Period 2" id="blockB">
<apex:outputPanel id="otpn1">
<apex:outputLabel ><b> Upper Date </b></apex:outputLabel>
<apex:inputField value="{!account.Rfleet_UpperDate_Period2__c}" html-disabled="{!bool}" id="acctype6"/>
<script>document.getElementById('{!$Component.acctype6}').disabled = {!bool}; </script>
<apex:inputField value="{!account.Rfleet_UpperMonth_Period2__c}" html-disabled="{!bool}" id="acctype7"/><br/><br/>
<script>document.getElementById('{!$Component.acctype7}').disabled = {!bool}; </script>
<apex:outputLabel ><b>Lower Date </b></apex:outputLabel>
<apex:inputField value="{!account.Rfleet_LowerDate_Period2__c}" html-disabled="{!bool}" id="acctype8"/>
<script>document.getElementById('{!$Component.acctype8}').disabled = {!bool}; </script>
<apex:inputField value="{!account.Rfleet_LowerMonth_Period2__c}" html-disabled="{!bool}" id="acctype9"/><br/><br/>
<script>document.getElementById('{!$Component.acctype9}').disabled = {!bool}; </script>
<apex:outputLabel ><b>Due Date </b></apex:outputLabel>
<apex:inputField value="{!account.Rfleet_DueDate_Period2__c}" html-disabled="{!bool}" id="acctype10"/>
<script>document.getElementById('{!$Component.acctype10}').disabled = {!bool}; </script>
<apex:inputField value="{!account.Rfleet_DueMonth_Period2__c}" html-disabled="{!bool}" id="acctype11"/>
<script>document.getElementById('{!$Component.acctype11}').disabled = {!bool}; </script>
</apex:outputPanel>
</apex:pageBlock>
</apex:panelGrid>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class Rfleet_PaymentConditions {
public Boolean bool {get;set;} public Boolean showSave{get;set;}
public Boolean showSubmit{get;set;} public Boolean showback{get;set;}
public string id; public account acc{get;set;}
public Rfleet_PaymentConditions(ApexPages.StandardController controller) {
bool = true;
showSave = true;
id=ApexPages.currentPage().getParameters().get('id');
}
public void save() {
bool =false;
showSave=false;
showSubmit=true;
showback=true;
} public PageReference back() { // PageReference newocp = new PageReference('/apex/RFLEET_PaymetCondition'); //
newocp.setredirect(true);
PageReference pageRef = new PageReference('/' + ApexPages.currentPage().getParameters().get('id')+'?inline=0');
return pageRef;
//return newocp; }
public void Submit() {
bool=false;
acc=[SELECT
Rfleet_DueDate_Period1__c,Rfleet_DueDate_Period2__c,Rfleet_DueMonth_Period1__c,Rfleet_DueMonth_Period2__c,Rfleet_LowerDate_Period1__c,Rfleet_LowerDate_Period2__c,Rfleet_LowerMonth_Period1__c,Rfleet_LowerMonth_Period2__c,Rfleet_UpperDate_Period1__c,Rfleet_UpperDate_Period2__c,Rfleet_UpperMonth_Period1__c,Rfleet_UpperMonth_Period2__c
FROM Account where id=:id]; insert acc;
}
}


System.QueryException: List has no rows for assignment to SObject Error is in expression '{!Submit}' in component apex:commandButton in page rfleet_paymetcondition: Class.Rfleet_PaymentConditions.Submit: line 39, column 1
Class.Rfleet_PaymentConditions.Submit: line 39, column 1. can u please solve the issue
– kiran k Aug 10 '15 at 12:29