Show only records owned by logged in user?
Using the standard Contact app as an example, how would I know which user is logged into Salesforce.com? The standard app returns all contacts that the user has access to, in my application I want to return only the records owned by the currently logged in user.
The login process happens in the SF_JSUtils Javascript provided, as shown below:
pre
function doLogin () {
Code: Select all
// as we render all pages into one file, let's check if this is a callback
if (window.location.href.indexOf("access_token") == -1) {
var client_id = SF_Settings['client_id'];
var redirect_url = SF_Settings['redirect_url'];
var login_url = SF_Settings['login_url'];
var url = login_url + "?response_type=token&display=touch&display=touch&client_id=" +
client_id + "&redirect_uri=" + encodeURI(redirect_url);
// let's go to Salesforce to login
window.open(url, "_self");
}
else { // yes, this is a callback
// save token, url into local storage
saveAuthCodeInLocalStorage();
// navigate to page
Appery.navigateTo('mypage', {reverse: false});
}
}
/pre
I would imagine that the solution would be to grab the userid returned somewhere in the code above and store it in a local variable, which can then be used to create the SOQL call. But I cannot figure out how. I imagine this has been done before?