I'm trying to use the Salesforce documented method for determining if we're in the Salesforce1 UI when viewing a page in my app but for some reason, this code is not working the browser version of Salesforce (one/one.app)
if( (typeof sforce != 'undefined') && (sforce != null) ) {
// Salesforce1 navigation
sforce.one.navigateToSObject(aId);
}
sforce is not defined in /one/one.app ... Any ideas?
Attribution to: greenstork
Possible Suggestion/Solution #1
The reason why I wasn't able to find sforce in my console was because the Visualforce page is inside of an iframe. I needed to change the context of the console to operate from the frame rather than the top frame in Chrome
Attribution to: greenstork
Possible Suggestion/Solution #2
Just guessing by the docs :
Are you trying to run the app in your browser : may be this could be the reason why it is not working
The if statement checks to see if the sforce object is available and usable. This is only true if the page is running inside Salesforce1.
If the sforce object isn’t available, trying to use it to navigate anywhere results in a JavaScript error, and no navigation
Attribution to: Rao
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/33079