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
Vinnie BVinnie B 

Basic help with SOQL query within a VF page

I'm brand new to VF programming and have encountered something I'm hoping is a simple problem.

 

My page accepts a contact ID as an argument.  I've confirmed this is successfully passed in and saved as a string named cidValue.

 

My problem is getting information on this contact from the database.  I tried this and it doesn't work.

 

  List<Contact> cons = [Select Id, Name from Contact WHERE Id = :cidValue];

 

I tried converting the string to an ID and putting the ID into a map of IDs named contactIDs.  That didn't work.

 

  List<Contact> cons = [Select Id, Name from Contact WHERE IN = :contactIDs];

 

Finally, I tried using the ID itself.  That worked!  Of course, that's not a viable workaround.  :)

 

  List<Contact> cons = [Select Id, Name from Contact WHERE Id = '0000111000111'];

 

I'm hoping this is a basic SOQL issue.  Any help would be greatly appreciated.

Best Answer chosen by Admin (Salesforce Developers) 
itsmemarioitsmemario

Have you checked on the Debug log what line is triggering this error?

 

 

All Answers

Vinnie BVinnie B

Oddly, I just tried the following line.  Now I get an Authorization Required page.  I have check to make sure this profile has access to the VF Page, the Class and the Contact object.

 

 List<Contact> cons = [Select Id, Name from Contact WHERE Id = :contactIDs[0]];

Vinnie BVinnie B

I figured it out.  It was a dumb error.  However, I am now getting the Authorization Required message and can't seem to get past that.  I'll peruse the many threads on this.

itsmemarioitsmemario

Have you checked on the Debug log what line is triggering this error?

 

 

This was selected as the best answer
itsmemarioitsmemario
please share your code (VF & Class)
Vinnie BVinnie B

Yes, the logs pointed me in the right direction.  What I had not done is add the site user to the list of users who's logs we're tracking (under Monitoring).  That did it.

 

There were some other stupid errors that I figured out on my own.


THANKS!!

itsmemarioitsmemario
Cool!

Cheers!