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
MeerMeer 

String Operations

Hi..

 

I want to edit the retUrl for the below url

 

<apex:commandButton value="New" action="{!URLFOR($Action.Fin_Periods__c.New)"/>

 

I concatenated the desire url : "retURL%3D%2Fapex%2FFin_Periods" by this 

 

<apex:commandButton value="New" action="{!URLFOR($Action.Fin_Periods__c.New) & "&retURL%3D%2Fapex%2FFin_Periods"}"/>


but it dint work.. 

 

Any ideas???

 

 

Regards,

Meer

Navatar_DbSupNavatar_DbSup

Hi,

 

Try the below code snippet for appending the retURL in URLFOR

 

<apex:commandButton value="New" action="{!URLFOR($Action.Fin_Periods__c.New,null, retURL='%3D%2Fapex%2FFin_Periods'])}"/>

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

VahidVahid

Hey,

 

What do you want to actually? are you using any controller?, please make it clear.

 

And i think you want to redirect to a page on click New button.

 

If this is case, you can use this way (here assuming you are not using controller:

 

<apex:commandButton value="New" onclick="window.location.href={!URLFOR($Action.Fin_Periods__c.New)&retURL=/apex/Fin_Periods"}"/>

 

Don't put encoded characters.

 

And if you are using controller then you can use page Reference and modify your url.

 

If this solve your problem mark this as Solution.

 

Thanks
Abdul Vahid (iBirds' Software Services Pvt. Ltd.)
http://www.aslambari.com/salesforce-freelancer-consultant_aslam.html
Email: ab.vahid@gmail.com
Skype: ab.vahid
Mobile: +91-9214363316

MeerMeer

Dear Navatar, 

 

Sorry the snippet didn't work, have u put the barces in the end intentionally??

I removed them as i was getting syntax error, but even then it didn't work.

 

Thanks

 

Regards,

Meer

MeerMeer

Dear Vahid,

 

Yes you did understand very well, i want to redirect the page to the mentioned URL.

Actually when i use  !URLFOR($Action.Fin_Periods__c.New)  it returns the URL containing the retURL, I just want to replace it with my own retURL, as concatenation trick didn't work..

 

 

besides,  from your above snippet I am getting the following error:

 

Error: onclick="window.location.href={!URLFOR($Action.Fin_Periods__c.New)&retURL=/apex/Fin_Periods"}" EL

Expression Unbalanced: ... {!URLFOR($Action.Fin_Periods__c.New)&retURL=/apex/Fin_Periods"}

 

Regards,
Meer 

Starz26Starz26

doing this outputs the link just fine:

 

<apex:outputLink value="{!URLFOR($Action.Account.New)}&retURL=/apex/Fin_Periods">

 

so you should be able to:

 

{!URLFOR($Action.Fin_Periods__c.New)}&retURL=/apex/Fin_Periods"

 

 

MeerMeer

Hi,

 

Still not good enough..

 

Actually what I am looking here is that when ever i create a new period after saving it it should return to the Period tab i.e at Peirod home page.

 

so, i try to redirect the page from the New button by passing the URL, after your snippet I am getting the following URL in address bar:

 

https://ap1.salesforce.com/a0A/e?retURL=%2Fapex%2FFin_Periods&retURL=%2Fapex%2FFin_Periods

 

In this there are two retURL, first from the $Action.Fin_Period__c command and second which we have concatenated, hence the window is redirected to the first retURL.

 

I hope you can undertstand what I am focusing on

 

Regards,

Meer

Starz26Starz26

Why not just do:

 

String baseURL = URL.getSalesforceBaseUrl().toExternalForm();
String productPrefix = ProductOBJAPINAME.sObjectType.getDescribe().getKeyPrefix();

        PageReference pr = New PageReference(baseURL + '/' + productPrefix + '/');
        pr.setRedirect(True);