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
ARUNBLIKESCLOUDARUNBLIKESCLOUD 

Standard button override and retURL issue

Hello folks,

I have been participating in this forum for a while using my old names (aru4912 or arub82) ..both accounts are locked out and hence I am back with my new login.

 

I've been facing a weird behavior with respect to retURL during button override.

 

Use case: Edit Account button is overrided with a VF page. I am setting the retURL & cancelURL params and creating the page reference from the controller.

 

Issue: the override works fine from a normal flow. When I search for an account A using the standard salesforce search and then click on the 'Edit' button on the account A from the search result page, then I'm taken to the Account edit page. But after clicking 'save' , I lose the search results though I am taken back to the search page which now says a message: 'Error: Please enter a search string at least 2 characters long.'

 

I face this retURL or cancelURL issue only while returning back to search screen. Any hints folks ?

 

 

Regards,

A B

 

bob_buzzardbob_buzzard

It sounds like your retURL is sending you back to the search "generate results" style page, and this is expecting to find the query string in the URL.  It finds null/empty string and displays an error message that it is too short.

 

What is your retURL?  If you are trying to do something like browser back, this is the behaviour I would expect. 

bob_buzzardbob_buzzard

I've just had a play with the standard pages and reproduced this.

 

What is happening is that you are hitting the advanced search URL as follows:

 

https://na6.salesforce.com/search/AdvancedSearch?searchType=1&sen=0&setLast=1&sbstr=

You then submit your search and get redirected to :

 

 

https://na6.salesforce.com/search/SearchResults?searchType=2&str=sdasd&search=Search&sen=0

 

which contains the results.  You then click on the details and go through to your VF page.  If your retURL returns a link to the previous page and just picks up the base URL, it will go to:

 

 

https://na6.salesforce.com/search/SearchResults

 

and this gives me the page and error message that you are referring to.

ARUNBLIKESCLOUDARUNBLIKESCLOUD

Bob,

Thanks for your response.

 

I set myretURL in the page reference like this ..

 

PageReference pageRef = new PageReference('/'+acctRecord.Id+'/e');
 
pageRef.getParameters().put('retURL',ApexPages.currentPage().getParameters().get('retURL'));

 

Do you see an issue in this way ? I know of only this approach to get the retURL

bob_buzzardbob_buzzard

I would surmise that the line of code:

 

ApexPages.currentPage().getParameters().get('retURL'));

 

is giving you the base URL that you came from (search results) without any parameters.

 

You can tell this by looking at the URL of the page that gave you the error - what is the URL in your browser?

ARUNBLIKESCLOUDARUNBLIKESCLOUD

Bob,

The retURL on the browser looks fine atleast :

 

retURL=/search/SearchResults?searchType=1&sen=00Q&setLast=1&sbstr=ELR+sample&search=+Go%21+

 

But after editing the record and clicking on 'Save' or on just clicking on cancel without any editing, I get to an empty search result page with that error.

 

Little perplexed by this behavior ....

 

 

 

ARUNBLIKESCLOUDARUNBLIKESCLOUD

The URL on the search page after return is :

 

https://cs3.salesforce.com/search/SearchResults?searchType=1

 

The retURL on the VF page is :

 

retURL=/search/SearchResults?searchType=1&sen=00Q&setLast=1&sbstr=ELR+sample&search=+Go%21+

 

bob_buzzardbob_buzzard

You will need to escape the retURL string before adding it to the PageReference parameters.   I don't know if there are any utilities available in SalesForce to help with this, but in the first instance you could try replacing '&' with '&'.

ARUNBLIKESCLOUDARUNBLIKESCLOUD
That may be a possible cause ... but let me try escaping spl characters to confirm it. Thanks for the tips Bob. Will keep the thread posted !