when I tried executing this code I get the error on the visualforce page
System.QueryException: List has more than 1 row for assignment to SObject
visualforce page:
<apex:page id="RelatedContactsInlineVF"
standardController="Contact"
extensions="RelatedContactsInlineContExt"
title="Related Accounts" showChat="false" showHeader="false" sideBar="false">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!conRec}" var="cont">
<apex:column value="{!cont.Name}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
controller class
public without sharing class RelatedContactsInlineContExt {
public List<Contact> conRec{get;set;}
public id conRecId;
public RelatedContactsInlineContExt(ApexPages.StandardController stdController) {
if(ApexPages.currentPage().getParameters().get('id')!=null){
conRecId = [select id from contact where MailingCity=
:ApexPages.currentPage().getParameters().get('MailingCity')].id;
if(conRecId!= null){
conRec=[select id, Name, MailingCity, Phone from contact where id =: conRecId];
}
}
}
}