You need to sign in to do that
Don't have an account?
אביב קסוטו
List has no rows for assignment to SObject although query returns rows
I am trying to display a selectList in a visualforce page using a custom controller i built.
I get an "List has no rows for assignment to SObject" error when trying to preview the page, but running the query in the developer console, returns the rows.
here is my page:
<apex:page Controller="BpmIcountPayment"> <apex:param name="first_name" value="Account.FirstName"/> <apex:param name="last_name" value="Account.LastName"/> <apex:param name="id" value="Account.idnumber__c"/> <apex:param name="address" value="Account.Address"/> <apex:form > <apex:selectList value="{!productsTitle}" multiselect="false"> <apex:selectOptions value="{!ProductsLov}"></apex:selectOptions> </apex:selectList> </apex:form> </apex:page>
and my controller:
public class BpmIcountPayment{ private final Account account; public String productsTitle { get { return 'products for sale'; } set; } public BpmIcountPayment() { account = [SELECT Id, Name, Site FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')]; } public Account getAccount() { return account; } public List<SelectOption> getProductsLov() { List<SelectOption> products = new List<SelectOption>(); List<Product2> productsList = [SELECT Id, Name, Family FROM Product2 WHERE (Family = 'ShopProduct') OR (Family = 'CourseParent') OR (Family = 'SFCourseProgram')]; system.debug(productsList); for (Product2 currProduct : productsList) { products.add(new SelectOption(currProduct.Id, currProduct.Name)); } return products; } }
As you are trying to get the account id from the URL.
Have you tried passing any id of account to the url when previewing the visualforce.
preview url : after apex/vfpage_name pass the id of any account like this: Please try this, if the problem sustain then let me know.
All Answers
As you are trying to get the account id from the URL.
Have you tried passing any id of account to the url when previewing the visualforce.
preview url : after apex/vfpage_name pass the id of any account like this: Please try this, if the problem sustain then let me know.
Tried that, still the same error.
Also just to clarify, currently i am only looking to display the values of the query in the "getProductLov" function.
I have changed my visualforce page to this now: