You need to sign in to do that
Don't have an account?
:Error:SObject row was retrieved via SOQL without querying the requested field: Bid__c.Name
I receieve the following error with this Apex Controller
System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Bid__c.Name
Apex Controller:
public with sharing class RenderController
{
public RFQ__C rfq {get; set;}
public boolean privatefleet {get; set;}
public boolean Dryvan{get; set;}
public boolean Flatbed{get; set;}
public boolean Reefer{get; set;}
public boolean IMDL{get; set;}
public boolean LTL{get; set;}
public boolean RFI{get; set;}
public Bid__c bid{get;set;}
public RenderController()
{
rfq = new RFQ__C();
String rfqid = Apexpages.Currentpage().getparameters().get('rfqid');
rfq = [select name,f_Account_Owner__c,Account_Owner__c,Mode_s__c from RFQ__c where id=:rfqid];
if(rfq.Mode_s__c.contains('Private Fleet'))
{
privatefleet = true;
bid = [select Will_Load_Following_Trailers__c,Days_of_Week__c,Must_be_food_grade_trailer__c,Driver_Work__c,Lead_Time__c,Shipper_Hours_To__c,Shipper_Hours_From__c,Cons_Hours_To__c,Cons_Hours_From__c from Bid__C where RFQ__C=:rfqid and Modes__C = 'Private Fleet'];
}
if(rfq.Mode_s__c.contains('Dry Van'))
{
}
if(rfq.Mode_s__c.contains('Flatbed'))
{
Flatbed = true;
bid = [select Ready_at__c,Securing_Accessories__C,Deliver_by__c,Level_of_flexibility__c,Are_moves_Over_Dimensional__c,Dimensions__c,Well_Space_Needed_or_Floor_Space__c,Tarps__c,Products_Overhang_on_Front_or_Rear__c from Bid__C where RFQ__C=:rfqid and Modes__C = 'Flatbed'];
}
if(rfq.Mode_s__c.contains('Reefer'))
{
Reefer= true;
bid = [select Temp_Low_del__c,Temp_High_del__C from Bid__C where RFQ__C=:rfqid and Modes__C = 'Reefer'];
}
if(rfq.Mode_s__c.contains('IMDL'))
{
IMDL= true;
bid = [select Container_Size__c,f_IMDL_Opportunity_Type__C,f_Shipment_Types__c,f_Current_IMDL_provider_types__c,f_Incumbent_IMDL_Providers__c,f_Other_IMDL_providers_notes__c from Bid__C where RFQ__C=:rfqid and Modes__C = 'IMDL'];
}
if(rfq.Mode_s__c.contains('LTL'))
{
LTL= true;
bid = [select LTL_Class__c,Class_Distribution_Notes__C,FAK_Applicable__c,FAK_Notes__c,Tariff_Base_Year__c,FSC_Schedule__c from Bid__C where RFQ__C=:rfqid and Modes__C = 'LTL'];
}
if(rfq.Mode_s__c.contains('RFI'))
{
RFI= true;
bid = [select RFI_Required__c,RFI_Status__C,RFI_Dependent__c,RFI_Due_Date__c from Bid__C where RFQ__C=:rfqid and Modes__C = 'RFI'];
}
}
public pagereference save()
{
upsert bid;
Pagereference pg = new Pagereference('/a0B/o');
return pg;
}
public PageReference Cancel()
{
Pagereference pg = new Pagereference('/a01/o');
return pg;
}
VF page:
<apex:page controller="RenderController" tabStyle="RFQ__c">
<apex:form >
<apex:sectionHeader title="RFQ Edit" subtitle="New RFQ"/>
<apex:pageBlock id="rfqmain" title="RFQ Information" mode="Edit">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!Cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="RFQ Information">
<apex:outputField value="{!rfq.name}"/>
<apex:outputField value="{!rfq.f_Account_Owner__c}"/>
<apex:outputField value="{!rfq.Account_Owner__c}"/>
<apex:outputField value="{!rfq.Mode_s__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Information">
<apex:outputField value="{!bid.name}"/>
<apex:outputField value="{!bid.Modes__c}"/>
<apex:outputField value="{!bid.RFQ__c}"/>
<apex:outputField value="{!bid.f_RFQ_Due_Date__c}"/>
<apex:outputField value="{!bid.Lanes__c}"/>
<apex:outputField value="{!bid.RFQ_Status__c}"/>
<apex:outputField value="{!bid.Expected_LPD__c}"/>
<apex:outputField value="{!bid.Bid_Status__c}"/>
<apex:outputField value="{!bid.Bid_Stage__c}"/>
<apex:outputField value="{!bid.FSC_Type__c}"/>
<apex:outputField value="{!bid.FSC_Peg__c}"/>
<apex:outputField value="{!bid.LPD_Goal__c}"/>
<apex:outputField value="{!bid.Total_LPD__c}"/>
<apex:outputField value="{!bid.Send_to_Pricing_Team__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Notes">
<apex:outputField value="{!bid.Notes__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="private fleet" id="Privatefleet" rendered="{!Privatefleet}">
<apex:inputField value="{!bid.Will_Load_Following_Trailers__c}"/>
<apex:inputField value="{!bid.Days_of_Week__c}"/>
<apex:inputField value="{!bid.Must_be_food_grade_trailer__c}"/>
<apex:inputField value="{!bid.Driver_Work__c}"/>
<apex:inputField value="{!bid.Lead_Time__c}"/>
<apex:inputField value="{!bid.Shipper_Hours_To__c}"/>
<apex:inputField value="{!bid.Shipper_Hours_From__c}"/>
<apex:inputField value="{!bid.Cons_Hours_To__c}"/>
<apex:inputField value="{!bid.Cons_Hours_From__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Dry Van" id="Dryvan" rendered="{!Dryvan}">
</apex:pageBlockSection>
<apex:pageBlockSection title="Flatbed" id="Flatbed" rendered="{!Flatbed}">
<apex:inputField value="{!bid.Ready_at__c}"/>
<apex:inputField value="{!bid.Securing_Accessories__c}"/>
<apex:inputField value="{!bid.Deliver_by__c}"/>
<apex:inputField value="{!bid.Level_of_flexibility__c}"/>
<apex:inputField value="{!bid.Are_moves_Over_Dimensional__c}"/>
<apex:inputField value="{!bid.Dimensions__c}"/>
<apex:inputField value="{!bid.Well_Space_Needed_or_Floor_Space__c}"/>
<apex:inputField value="{!bid.Tarps__c}"/>
<apex:inputField value="{!bid.Products_Overhang_on_Front_or_Rear__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Reefer Requirements" id="Reefer" rendered="{!Reefer}">
<apex:inputField value="{!bid.Temp_Low_del__c}"/>
<apex:inputField value="{!bid.Temp_High_del__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Intermodal" id="IMDL" rendered="{!IMDL}">
<apex:inputField value="{!bid.Container_Size__c}"/>
<apex:inputField value="{!bid.f_IMDL_Opportunity_Type__c}"/>
<apex:inputField value="{!bid.f_Shipment_Types__c}"/>
<apex:inputField value="{!bid.f_Current_IMDL_provider_types__c}"/>
<apex:inputField value="{!bid.f_Incumbent_IMDL_Providers__c}"/>
<apex:inputField value="{!bid.f_Other_IMDL_providers_notes__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="LTL" id="LTL" rendered="{!LTL}">
<apex:inputField value="{!bid.LTL_Class__c}"/>
<apex:inputField value="{!bid.Class_Distribution_Notes__c}"/>
<apex:inputField value="{!bid.FAK_Applicable__c}"/>
<apex:inputField value="{!bid.FAK_Notes__c}"/>
<apex:inputField value="{!bid.Tariff_Base_Year__c}"/>
<apex:inputField value="{!bid.FSC_Schedule__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="RFI" id="RFI" rendered="{!RFI}">
<apex:inputField value="{!bid.RFI_Required__c}"/>
<apex:inputField value="{!bid.RFI_Status__c}"/>
<apex:inputField value="{!bid.RFI_Dependent__c}"/>
<apex:inputField value="{!bid.RFI_Due_Date__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="System Information">
<apex:outputField value="{!bid.CreatedBy}"/>
<apex:outputField value="{!bid.LastModifiedBy}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Like
Select Name, ...... from Bid__c
I have tried to include the neccessary fields also, but it is showing error as:
System.QueryException: List has more than 1 row for assignment to SObject
Class.RenderController.<init>: line 19, column 1
[Select.... from Bid__c where ......limit 1]
How to implement these two SObject rows in my Apex Controller?
rfq = [select name,f_Account_Owner__c,Account_Owner__c,Mode_s__c from RFQ__c where id=:rfqid];
bid = [select name,Lanes__C,RFQ__c,Expected_LPD__c,Total_LPD__c,Modes__c,Bid_Stage__c,FSC_Type__c,FSC_Peg__c,LPD_Goal__c,
Send_to_Pricing_Team__c,Bid_Status__c,RFQ_Status__c, f_RFQ_Due_Date__c from Bid__c where id=:rfqid];
public .....ffq {get; set;}
Use limit 1 in SOQL queries