Find your content:

Search form

You are here

Salesforce1-specific navigation issue, sforce not defined in browser S1

 
Share

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

http://www.salesforce.com/us/developer/docs/salesforce1/index_Left.htm#CSHID=vf_dev_best_practices_pages_multipurpose.htm|StartTopic=Content%2Fvf_dev_best_practices_pages_multipurpose.htm|SkinName=webhelp

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

My Block Status

My Block Content