function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chenna1234chenna1234 

Unable to Insert Quotes into Accnt,Oppy

Hi All,

 

I am unable to insert qoute into account & oppportuntiy. Can you please help me out.....

 

Error Message: System.QueryException: List has no rows for assignment to SObject 
Class.QuickqouteUI.InsertQuoteToAccount: line 28, column 1
Class.QuickqouteUI.<init>: line 12, column 1

 

VF Page & Controller:

<apex:page controller="QuickqouteUI" action="{!InsertQuoteToAccount}" showHeader="false">
 <apex:sectionHeader title="Quote Details"/>
  <apex:form >
<style>
     .labelCol
     {
         font-family:"Times New Roman"
         color:black font;
     }
 </style>
  <style>
  .inactiveTab {
        background-color: ????;
        font-family:"Times New Roman"
        font-weight:bold;
        color:black;
        background-image:none
      }
</style>
      <apex:pageBlock >
          <apex:pageBlockSection columns="1"  >
              <apex:inputField value="{!objRoofDetails.Quote_description__c}" />
               <apex:inputField value="{!objRoofDetails.City_State__c}" />
               <apex:inputField value="{!objRoofDetails.Install_Date__c}" />
          </apex:pageBlockSection>
          <apex:pageBlockSection columns="1" Title="Solar System">
              <apex:pageBlockSectionItem >
                  <apex:outputLabel value="Description"></apex:outputLabel>
                  <apex:inputText />
              </apex:pageBlockSectionItem>
              <apex:pageBlockSectionItem >
                  <apex:outputLabel value="System price"></apex:outputLabel>
                  <apex:inputText />
              </apex:pageBlockSectionItem>
              <apex:pageBlockSectionItem >
                  <apex:outputLabel value="Description"></apex:outputLabel>
                  <apex:tabPanel id="tabpanel" immediate="true" reRender="tabpanel">
                  <apex:tab label="Roof 1">
                      <table>
                          <tr>
                              <td align="right"><apex:outputLabel value="Description" styleClass="labelCol" ></apex:outputLabel></td>
                              <td><apex:inputText /></td>
                              <td></td>
                          </tr>                          
                          <tr>
                              <td align="right"><apex:outputLabel value="Modules per strings" styleClass="labelCol" ></apex:outputLabel></td>
                              <td><apex:inputText /></td>
                              <td><a href="http:google.com">Design Tools</a></td>
                          </tr>
                          <tr>
                              <td align="right"><apex:outputLabel value="Total parallel strings" styleClass="labelCol" ></apex:outputLabel></td>
                              <td><apex:inputText /></td>
                              <td></td>
                          </tr>
                          <tr>
                              <td align="right"><apex:outputLabel value="Inverter Manufaturer" styleClass="labelCol" ></apex:outputLabel></td>
                              <td>
                                  <apex:selectList id="Inventers" size="1" label="Direction">
                                             <apex:selectOptions value="{!Inventers}" ></apex:selectOptions>
                                   </apex:selectList>
                              </td>
                              <td></td>
                          </tr>
                          <tr>
                              <td align="right"><apex:outputLabel value="Inventer Model" styleClass="labelCol" ></apex:outputLabel></td>
                              <td>
                                  <apex:selectList id="Model" size="1" label="Direction">
                                             <apex:selectOptions value="{!Inventers1}"></apex:selectOptions>
                                   </apex:selectList>
                              </td>
                              <td></td>
                          </tr>
                          <tr>
                              <td align="right"><apex:outputLabel value="Inverter Count" styleClass="labelCol" ></apex:outputLabel>
                              </td>
                              <td><apex:inputText /></td>
                              <td></td>
                          </tr>
                      </table>                      
                     
                  </apex:tab>
                  <apex:tab label="Roof 2">
                   <table>
                          <tr>
                              <td align="right"><apex:outputLabel styleClass="labelCol" value="Description"></apex:outputLabel></td>
                              <td><apex:inputText /></td>
                              <td></td>
                          </tr>                          
                          <tr>
                              <td align="right"><apex:outputLabel styleClass="labelCol" value="Modules per strings"></apex:outputLabel></td>
                              <td><apex:inputText /></td>
                              <td><a href="http:google.com">Design Tools</a></td>
                          </tr>
                          <tr>
                              <td align="right"><apex:outputLabel styleClass="labelCol" value="Total parallel strings"></apex:outputLabel></td>
                              <td><apex:inputText /></td>
                              <td></td>
                          </tr>
                          <tr>
                              <td align="right"><apex:outputLabel styleClass="labelCol" value="Inverter Manufaturer"></apex:outputLabel></td>
                              <td>
                                  <apex:selectList id="Inventers1" size="1" label="Direction">
                                             <apex:selectOptions value="{!Inventers}"></apex:selectOptions>
                                   </apex:selectList>
                              </td>
                              <td></td>
                          </tr>
                          <tr>
                              <td align="right"><apex:outputLabel styleClass="labelCol" value="Inventer Model"></apex:outputLabel></td>
                              <td>
                                  <apex:selectList id="Model1" size="1" label="Direction">
                                             <apex:selectOptions value="{!Inventers}"></apex:selectOptions>
                                   </apex:selectList>
                              </td>
                              <td></td>
                          </tr>
                          <tr>
                              <td align="right"><apex:outputLabel value="Inverter Count" styleClass="labelCol" ></apex:outputLabel>
                              </td>
                              <td><apex:inputText /></td>
                              <td></td>
                          </tr>
                      </table>           
                  </apex:tab>
                  <apex:tab label="Roof 3"></apex:tab>
                   <apex:tab label="Roof 4"></apex:tab>
                   </apex:tabPanel>
              </apex:pageBlockSectionItem>
           </apex:pageBlockSection>
      </apex:pageBlock>
  </apex:form>
</apex:page>

 

Apex Controller:

public with sharing class QuickqouteUI {
    
    public Roof_Details__c objRoofDetails{get;set;}
    public Quote objquote{get;set;}
    private String accID{get;set;}
    public QuickqouteUI()
    {
        
    objRoofDetails = new Roof_Details__c();
    objquote = new Quote();
    accID = '0038000000h4oyM';
InsertQuoteToAccount();
    }
public List<SelectOption> getInventers() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('SunPower','SunPower'));
        options.add(new SelectOption('SunPower','NonSunPower'));
        return options;
    }
public List<SelectOption> getInventers1() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('6.0kW (Model PVI-6000-OUTD)', '7.0kW (Model PVI-6000-OUTD)'));
        options.add(new SelectOption('8.0kW (Model PVI-6000-OUTD)', '8.0kW (Model PVI-6000-OUTD)'));
        return options;
    }
public void InsertQuoteToAccount(){
       
        opportunity objopp = [select account.name from opportunity where AccountId=: accID];
        objquote.name ='testi';
        objquote.opportunityid = objopp.id;
        insert objquote;
    }
}

Best Answer chosen by Admin (Salesforce Developers) 
JBabuJBabu

Hi,

 

accID = '0038000000h4oyM'; - this not a valid account.

Also dont hard code any accounts. They differ from orgs.

 

Thanks,

Babu.

All Answers

JBabuJBabu

Hi,

 

accID = '0038000000h4oyM'; - this not a valid account.

Also dont hard code any accounts. They differ from orgs.

 

Thanks,

Babu.

This was selected as the best answer
chenna1234chenna1234

please let me know how i need to proceed this?

 

If u don't mind ..can you please make any changes that required  to controller?

chenna1234chenna1234

Accid='0018000000UqMZO'

 

Error message: now its throwing this error message

 

System.LimitException: DML currently not allowed 
Class.QuickqouteUI.InsertQuoteToAccount: line 31, column 1
Class.QuickqouteUI.<init>: line 12, column 1

chenna1234chenna1234

Thanks....!!!!