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
Dev@Force.ax647Dev@Force.ax647 

Redirect with bookmark

I have to redirect page on  a url with bookmark(#) on page. But when I redirect URL is encoded and convert # into %23 and because of that page dont scroll to the bookmark.

 

        PageReference pr=Page.SamplePage;
        pr.getParameters().put('id',obj.Id+'#'+obj.Name);
        return pr;

 

Can any body tell me how to redirect page with a bookmark on that page?

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

Use setAnchor instead:

 

PageReference pr = Page.SamplePage;
pr.getParameters().put('id',obj.Id);
pr.setAnchor(obj.Name);
return pr;