function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
di_zoudi_zou 

Getting an error when trying to follow the tutorial for creating a custom controller

I am trying to create a custom Visualforce page with a custom controller by following the example on this page:

http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_custom.htm

However, when I view the page that uses the code given in the example, I get this error:

List has no rows for assignment to SObject An unexpected error has occurred. Your development organization has been notified.

I just copied and pasted the code from the example into a custom class and a custom visualforce page. How do I fix this issue? Thanks!

SLockardSLockard

You probably just need to provide an id to an account in your org. at the end of your url for the visualforce page put ?id=00012JD2312JKDX

But actually put a real Id of one of your accounts.

di_zoudi_zou

Ok thanks. Is there a way to automatically do that when I navigate to the page though?

SLockardSLockard

You would have to make a button on the account layout page and for that button just navigate to na9.salesforce.com/apex/YourPage?id={!Account.Id}

But replace that link with your actual one.

di_zoudi_zou

What I'm trying to do is to have a tab on the Customer Portal that shows all the cases in the account of that user. So if user A of company B logs into the customer portal and clicks on this tab, he will see all the cases for company B and not just the cases he opened. So I guess I don't really want a button on the Accounts page. I would like to be able to have the id in the link for the tab I am creating. How would I go about doingg this?

SLockardSLockard

So in the visualforce page, you can access the user fields by {!$User.fieldName} So you would want to show the list based on the user, to do that the query would selected all the Cases where createdBy = user id or however you made the relationship you want.

di_zoudi_zou

I can get the list of cases created by the user. That is not the problem. I am trying to get a list of ALL the cases of the Account of the user, not just the ones he created.

SLockardSLockard

Okay, try querying cases where Case.AccountId = User.AccountId