You need to sign in to do that
Don't have an account?
System.QueryException: List has more than 1 row for assignment to SObject
Hi All,
I am trying to send the values from controller to visualforce input text filed through getters and setters.But here i am getting query exception.
mycode is as follows:
<apex:page standardController="House_Bill_Of_Ladding__c" extensions="x1_validate">
<apex:form>
<apex:outputLabel value="SFN Control No." /></td>
<apex:inputField id="sfn" value="{!House_Bill_Of_Ladding__c.SFN_Number__c}" style="width:82px">
</apex:inputField> </td>
<apex:outputLabel value="Voyage No." ></apex:outputLabel></td>
<apex:inputText id="voy" value="{!hblvoyage}" style="width:82px">
</apex:inputText> </td>
<apex:commandLink value="Get" />
</apex:form>
</apex:page>
public class x1_validate
{
private House_Bill_Of_Ladding__c curr_record =new House_Bill_Of_Ladding__c();
Sea_Foot_Note__c SFN_voyage;
public string hblvoyage{get; set;}
public x1_validate(ApexPages.StandardController controller)
{
this.curr_record=(House_Bill_Of_Ladding__c)controller.getRecord();
string curr_sfn=curr_record.SFN_Number__c;
SFN_voyage=[SELECT Voyage_Number__c FROM Sea_Foot_Note__c where SFN_Number__c =: curr_sfn];
}
public Sea_Foot_Note__c gethblvoyage()
{
return SFN_voyage;
}
public void sethblvoyage(Sea_Foot_Note__c s)
{
this.SFN_voyage=s;
}
}
if i declared SFN_voyage return type as Sea_Foot_Note__c[] i can rectify the query exception.but again i am getting the following error.
Error: Compile Error: Return value must be of type: SOBJECT:chiranjeevi__Sea_Foot_Note__c at line 16 column 5
plz tell me is i am going in a correct way or not.i know that through setters and getters only we can pass the values from controller to visualforce.i can able to pass string value.but here i was unable to pass object value.if any one knows other solution plz give me example or plz check my code.my requirement is if i click on link i should populate the value to input text.
plzz help me.
Thanks in advance,
Manu..