You need to sign in to do that
Don't have an account?
populate Account Number when the user click Account lookup field
I want to populate Account Number when the user click Account lookup field,but i got this error System.QueryException: List has no rows for assignment to SObject Error is in expression '{!AccountPopulated}' in page lookup_populate Class.Lookup_populate.AccountPopulated: line 8, column 1.
public class Lookup_populate{
public String AccNo{get;set;}
public Id AccountId;
public Account cont {get;set;}
public void AccountPopulated()
{
cont = new Account();
cont=[select AccountNumber from Account where id=:AccountId limit 1];
AccNo= cont.AccountNumber;
}
}
<apex:page controller="Lookup_populate" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection id="accinfo" title="Account Information">
<apex:actionRegion >
<apex:inputField value="{!cont.ParentId}">
<apex:actionSupport event="onchange" action="{!AccountPopulated}" rerender="accinfo"/>
</apex:inputField>
</apex:actionRegion>
<apex:inputText value="{!AccNo}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
I got the solution