+ Start a Discussion
Manoj ParidaManoj Parida 

Redirection to another VF in the Account Layout from the VF included in the layout (Salesforce1)

Hi all,

I have added a "redirection.page" VF in the account layout. This internally (using a controller) redirects to another page based on the calculation in the controller. This works fine in Classic. However the issue is in Salesforce1, when the account detail page is loaded the entire page gets redirected to the next page from "redirection.page". The user is not in the account detail page anymore and he only sees the next vf page. Did someone face this issue? Please advice.

Manoj
SoleesSolees
There are 2 things you could use:

1. Detect SF1 from VF (maybe is not your case but you will use it):
function redirectToURL() {
     var isdtp = "{!$CurrentPage.parameters.isdtp}";
     if(isdtp != '') {
          sforce.one.navigateToURL("/apex/YOURPAGE?id={!prediagnostico.Id}");
     } else {
          window.open("/apex/YOURPAGE?id={!prediagnostico.Id}", "_blank");
     }
}

2. Detect SF1 from Apex Class:
public Boolean checkMobile {
        get {
            String userAgent = ApexPages.currentPage().getHeaders().get('USER-AGENT');
            if (userAgent.contains('Mobi')) {
                return true;
            }
            return false;
        }
        set;
    }