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
naresh johnnaresh john 

Visualforce error kindly help.

I have a custom object   Cobject. It has some data in it. with the help of  CobjectId, I am displaying the individual records in a visualforce page.This visualforce page has a custom controller. I am displaying records in the visualforce page with this url like https://cnp.na3.visual.force.com/apex/Cobjectdetail?id=a055000000AJDJT.

 

 

Its working well. But if I remove id value from the url(https://cnp.na3.visual.force.com/apex/Cobjectdetail?id=)

 

Its giving this error:  

 

Visualforce Error

Id value is not valid for the TCObject__c standard controller.

 

 

How to handle this error. With out the CobjectId, it should redirect to custom object tab. 

 

Please help me.

 

Thanks,

Naresh

Melvin_DeveloperMelvin_Developer

Hi,

You will have to handle this issue in your controller.
Simply check to see if the param is null in your constructor, if null return error else continue with the further operations.

I don't believe you can force a page redirect from your controller directly, I think this requires an action originating on your page. The normal way to handle this would be to display an error on your page and provide a link back to the previous page.

I hope this helps,

                             Melvin!

Pradeep_NavatarPradeep_Navatar

If you are using standard controller without extension then you should pass id as a query string parameter otherwise it will show an error.

 

naresh johnnaresh john

I am using extension. But still I am getting the error.

 

Thanks

Naresh

Imran MohammedImran Mohammed

You should the id value to make sure its not null

ID idVal = ApexPages.currentPage().getParameters().get('id');

you need to check prior using it.

If (idVal != null)

{

//actual functioanlity here

}

else

//custom message