You need to sign in to do that
Don't have an account?
AskYous
Redirect user to another VF page if no record id was set in URL
Hello,
I am currently trying implement a visualforce page with a standard controller and an extenssion. If the user puts in the url ".../apex/mySite?id=0000001", then that is great. But if the user enters ".../apex/mySite" with no record id in the URL, then the page crashes... as expected. How do I redirect the user to say record number 000001 if they don't enter a record if in the URL?
I've seen <apex:page action="..."> and it said this action should be used to redirect the user to another page, but I don't know how to do that.
Thanks in advanced!
In the mysite page display a message to enter the record id if they want go to the record page
Hi,
Use action method of page vf tag like this :
This worked in a way but now I have another problem. I used a custom object's record as the id by using the following code snippets:
pinnedContent = [SELECT id FROM KN_Content__c WHERE Pinned__c = true LIMIT 1];
PageReference pg = new PageReference('/apex/KnowledgeNetwork?id=' + pinnedContent.id);
However, the page redirects to the URL: apex/MySite?id={!pinnedContent}
It's not supposed to say ?id={!pinnedContent}, it's supposed to say ?id=000001, where 000001 is the pinnedContent.id.