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
FrodoFrodo 

returning a PageReference from Controller and Salesforce appends ?inline=1 to the URL

Hello All,

 

I have a custom page and controller.  I am trying to do some error handling within the controller as such:

 

public PageReference sendMail2PM(){
   

string PMID = [select Deliverable_Owner__c from P4_Contract_Deliverable__c where id = :this.cd.id].Deliverable_Owner__c;

 

string PMEmail = [select email from contact where id=:PMID].email;

 

if(PMEmail==null){
    PageReference errorPage = new PageReference('https://cs1.salesforce.com/apex/errorLanding');
    errorPage.setRedirect(true);
    return errorPage;
    }

 

}

 

My problem is that when the redirect happens, somehow "inline=1" gets appended to the URL.  It seems that when the inline parameter is present then the page renders without headers or sidebars.  I want the header and sidebar so users know they are still in saleforce.

 

Where is the "inline=1" coming from and how do I get rid of it?  Or else how do I make the redirect happen with headers and sidebars?

aalbertaalbert

I don't know the specifics to the "inline=1" parameter, but if you want to enforce the standard salesforce.com header and sidebar, make sure your apex page is defined as follows:

 

<apex:page showHeader="true" sideBar="true" .../> ... </apex:page>

 


 

 

Also, I notice you hardcode the URL "cs1.salesforce.com...". That will only work when in a Sandbox environment. You should use relative URL such as:

PageReference errorPage = new PageReference('/apex/errorLanding');

 


   

Message Edited by aalbert on 02-05-2009 08:37 AM
FrodoFrodo
Alas, I tried the sidebar="true" and showHeader="true", but they still do not appear.
lamayclamayc

Why do you have to do a redirect?

 

Couldn't you just

 

... 

 

if(PMEmail==null){
    PageReference errorPage = Page.errorLanding;
    return errorPage;

}

 

Granted, the URL in the browser taskbar is not updated ... but if you can live with that.

FrodoFrodo
Thanks Lamayc, I tried that method but unfortunately I still have the same issue.  I ended up putting in a call to SF support, so hopefully I will have it resolved soon.  Thanks for your help.
gv007gv007

('https://cs1.salesforce.com/apex/errorLanding'); instead of this use it

 

('../apex/errorLanding');you will get current page.

dbab_baltimoredbab_baltimore

Hello Frodo,

 

Have you get any solution for this issue? If yes, could you please let me the solution.

 

Ron WildRon Wild

You might try the following:

 

 

PageReference pageRef = new PageReference('/'+this.selectedAccount); pageRef.setRedirect(true); pageRef.getParameters().put('inline','0'); return pageRef;

 

 You'll end up with something like this...

 

https://na6.salesforce.com/0018000000M32zIAAR?inline=0&inline=1

 

... which will negate the inline=1 for you.

 

- R

 

we-mpwe-mp

I realize this is an old post....but has anyone found a solution to removing the inline=1 parameter? 

 

Thanks.

TankGirlTankGirl

putting

ref.getParameters().put('inline','0'); 

 only results in a douplicat param in the url so it looks like:

 

 

theurl?pram=something&inline=0&inline=1

 

I did find that if you switch the button/link to an outputlink it wont put that in url and will redirect to the page fine. You may just need to add action support to the link depending on what you are trying to do.

 

I have this working on many pages in many different ways so i know its posssible, but you just need to not use a commandlink/button

for example this button is in the case view:

<apex:outputpanel id="fullsearchbuttonpanel">

<apex:actionRegion id="FullSearchActionRegion">

<apex:outputLink id="btnFullSearch1" styleClass="btn fullsearchbutton" style="text-decoration: none;" value="{!fullSearchUrl}" target="_top" >

<apex:actionSupport event="onClick" action="{!getfullSearchUrl}" status="workstatustwo" />
Full Search
</apex:outputLink>
</apex:actionRegion>
</apex:outputpanel>

 

 

and the controller:

public string userKeywords{get;set;}

public PageReference getfullSearchUrl(){
	
string kywrds = this.userKeywords;
if(kywrds == NULL || kywrds == ''){kywrds = cse.Subject;}
kywrds = EncodingUtil.urlEncode(kywrds, 'UTF-8');
PageReference ref = new PageReference('/apex/knowledge' + '?product=' + cse.ccil_product2__c + '&id=' + cse.id+ '&keywords=' + kywrds );
ref.setRedirect(true);
return ref; }

 

since this is a controller extention for case the 'cse' is refrincing that... but its not inportant for what you are tying to do. Just wanted to show an example of it working.

 

Ted LangTed Lang

it works. you help me a lot.

Lee.ax1423Lee.ax1423

Thanks a lot..........

I got it.........

Mahmoud AbdelsalamMahmoud Abdelsalam

I tried the following and it is working as expected 

But this mark up in the Component 

    <a href="javascript:void(0);" onclick="{!c.gotoURL}"  >Link Title</a>

and this function inside the jsController        

 gotoURL : function(component, event, helper) { 
         var ctarget = event.currentTarget;
        var id_str = ctarget.dataset.value;
        console.log(id_str);
        
        var urlEvent = $A.get("e.force:navigateToURL"); 
        urlEvent.setParams({ "url":"/apex/VisualForcePageName")}); 
        urlEvent.fire(); 
    
    }