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
Terry411Terry411 

Page Navigation Salesforce1 verse Desktop

I'm working on a proof of concept that will allow us to run Reporting Services reports via a SF Action.  The SF1 users will be connected via Good and running within the firewall.  So connectivity will not be a problem.  

What I'm fighting is getting the links on my VF page to know if I'm running within SF1 or running from my Desktop browser.  When I run the code below, both the desktop and SF1 show the alert 'hello mobile'.  How do I get this to work from the Desktop?  The mobile link works perfectly.
<script> 
	function openTab(recid, recname) {
		var url = "http://crastrsrpt01.us.xxxxxx.com/ReportServer/Pages/ReportViewer.aspx?"
		url = url + "%2fProduction%2fTRSSales%2fProducer+Profile" 		
		url = url + "&contact=" + recid
		url = url + "&rs:Format=PDF"
		
		if((typeof sforce == 'undefined') || (sforce == null)) {
    		// Desktop navigation
    		alert('hello desktop - ' + sforce);
			window.location.href = url;
		} else {
    		// Salesforce1 navigation
    		alert('hello mobile - ' + sforce);
    		sforce.one.navigateToURL(url);
		}
	}
</script>


Best Answer chosen by Terry411
Terry411Terry411
Not sure what I was donig wrong but I have this working now.

<script type="text/javascript"> 
	function redirectToReportingServices(rptName, recId) {
		var url = "http://www.google.com";
		
		if(rptName == 'ProdProfile') {
			url = "http://crastrsrpt01.us.xxxxx.com/ReportServer/Pages/ReportViewer.aspx?";
			url = url + "%2fProduction%2fTRSSales%2fProducer+Profile";
			url = url + "&contact=" + recId;
			url = url + "&rs:Format=PDF";
		}
		
		if( (typeof sforce != 'undefined') && (sforce != null) ) {
    		// Salesforce1 navigation
    		sforce.one.navigateToURL(url);
		} else {
    		// Desktop navigation
			window.open(url);
		}
	}		
</script>