+ Start a Discussion
dkorba2k5dkorba2k5 

Bad ID value on Page Load

In an attempt to make our application bulletproof I'm trying to figure out how to catch the error when a VF page is loaded and has a bad ID value (either missing or incorrect value for that standard controller).  We're able to catch all other scenario's but haven't been able to figure out how to process that error.
TehNrdTehNrd

How is this bad Id being passed over?

 

I have noticed that some times a user will access a VF page with a custom button that is a link and the id will come over as null. It is as if the merge field in the link isn't populating before the user selects the button. 

dkorba2k5dkorba2k5
Here's the weird thing.  It's happening inconsistently .. it looks like mostly when the user is using tabbed browsing and opens a new tab with the existing URL.  I haven't been able to completely reproduce it yet but I keep getting Apex Error messages with an ID value being NULL.  I also need to catch if a creative user decides to put in an ID that's not valid
TehNrdTehNrd

Sounds exactly like what our users are encountering. I wonder if anyone from salesforce.com is aware of this issue. The obvious way to catch this is inspect the Page parameters in your contoller or extension and display an error if it is null.

 

Catching creative ids would probably be done with a try catch around the SOQL statement.

Message Edited by TehNrd on 07-30-2009 09:25 AM
dkorba2k5dkorba2k5
yeah so I do catch the null on the page parameters, I'll have to try the try/catch on the query and see.  Didn't think about that.  Thanks.