• Raja Rao DV
  • NEWBIE
  • 25 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

All of the queries on the sample apps have no Where clauses.  I need to put in a Where clause that limits the query to ownerId= the current user id.

I'm not sure how to capture the current UserId and what that would look like.

 

Here is what I have tried.

 

I edited this function in angular-force.js

            function salesforceSessionRefreshed(creds) {
                // Depending on how we come into this method, `creds` may be callback data from the auth
                // plugin, or an event fired from the plugin.  The data is different between the two.
                var credsData = creds;
                if (creds.data)  // Event sets the `data` object with the auth data.
                    credsData = creds.data;

                SFConfig.client = new forcetk.Client(credsData.clientId, credsData.loginUrl);
                SFConfig.client.setSessionToken(credsData.accessToken, apiVersion, credsData.instanceUrl);
                SFConfig.client.setRefreshToken(credsData.refreshToken);

                //added to get UserID
                var userId = credsData.userId;

                //Set sessionID to angularForce coz profileImages need them
                self.sessionId = SFConfig.client.sessionId;

                callback && callback();
            }

 And then I edited app.js with this where clause, on a custom object.

angular.module('Store', []).factory('Store', function (AngularForceObjectFactory) {
    //Describe the store object
    var objDesc = {
        type: 'Retail_Store__c',
        fields: ['Retailer_Store_Type__c', 'Account_Related_to__r.Name', 'Address_1__c', 'City__c', 'State__c', 'Phone__c',
            'Field_Team_Tier__c', 'Lat__c', 'Long__c', 'Location_Note__c', 'Id'],
        where: 'ownerId='+userId,
        orderBy: 'Account_Related_to__c',
        limit: 20
    };
    var Store = AngularForceObjectFactory(objDesc);

    return Store;
});

 Any Ideas?  Any help is appreciated.

 

  • August 28, 2013
  • Like
  • 0
Hi there,
I hope you are all excited and getting ready for the upcoming Summer Of Hacks hackathon! At the hackathon time flies by really fast and you don’t want to spend time installing and configuring multiple software required to build apps. So to help you with that, we have created a list of software and tools that you can pre-install before the hackathon and focus on building the app.

Software And Tools:

1. New Salesforce Account (https://developer.salesforce.com/ (https://developer.salesforce.com/" target="_blank))
In general, it's better to use new Salesforce account rather than an old one for the Hackathon so you have all the current features.
Tip: Add Network Access to "0.0.0.0" to "1.255.255.255" (Settings > Network Access) so you can login from any I.P. address.

2. Github (https://github.com/ (https://github.com/" target="_blank))
Make sure you have Github installed and configured. You can find instructions for Github CLI here: https://help.github.com/articles/set-up-git, for Windows GUI client here: https://windows.github.com/, and for Mac GUI client here: https://mac.github.com/.

3. Force.com CLI (http://force-cli.heroku.com/)
Force.com CLI allows you to interact with Salesforce. Use this tool to download your app (see: http://bit.ly/U5NboC (http://bit.ly/U5NboC" target="_blank)) to local machine so that you can later check-in your app to Github.

4.  Salesforce1 Mobile App  (http://www.salesforce.com/mobile/)
Install and try Salesforce1 Mobile app from Apple or Google Play app store to ensure your phone is compatible.

5. Salesforce1 Chrome Browser Plugin:(http://bit.ly/1qH8tWw )
It opens up Salesforce1 inside Chrome browser. You can use this to see how your app looks inside a mobile device. Tip: You can also debug your app by simply going to https://<instance>.salesforce.com/one/one.app

6. SOQL Tools
There are many tools for you to make and test REST calls and SOQL queries to Salesforce and here are couple of them. 1. Workbench (https://workbench.developerforce.com/login.php (https://workbench.developerforce.com/login.php" target="_blank)) and 2. A Chrome browser plugin called Advanced REST Client ( http://bit.ly/K5yopu (http://bit.ly/K5yopu" target="_blank))

7. Heroku + Canvas App (https://www.heroku.com (https://www.heroku.com" target="_blank)):
If you are planning to build a Heroku + Canvas App, make sure to register to Heroku and setup your Heroku environment.

@rajaraodv (http://twitter.com/rajaraodv" target="_blank)
Hi there,
I hope you are all excited and getting ready for the upcoming Summer Of Hacks hackathon! At the hackathon time flies by really fast and you don’t want to spend time installing and configuring multiple software required to build apps. So to help you with that, we have created a list of software and tools that you can pre-install before the hackathon and focus on building the app.

Software And Tools:

1. New Salesforce Account (https://developer.salesforce.com/ (https://developer.salesforce.com/" target="_blank))
In general, it's better to use new Salesforce account rather than an old one for the Hackathon so you have all the current features.
Tip: Add Network Access to "0.0.0.0" to "1.255.255.255" (Settings > Network Access) so you can login from any I.P. address.

2. Github (https://github.com/ (https://github.com/" target="_blank))
Make sure you have Github installed and configured. You can find instructions for Github CLI here: https://help.github.com/articles/set-up-git, for Windows GUI client here: https://windows.github.com/, and for Mac GUI client here: https://mac.github.com/.

3. Force.com CLI (http://force-cli.heroku.com/)
Force.com CLI allows you to interact with Salesforce. Use this tool to download your app (see: http://bit.ly/U5NboC (http://bit.ly/U5NboC" target="_blank)) to local machine so that you can later check-in your app to Github.

4.  Salesforce1 Mobile App  (http://www.salesforce.com/mobile/)
Install and try Salesforce1 Mobile app from Apple or Google Play app store to ensure your phone is compatible.

5. Salesforce1 Chrome Browser Plugin:(http://bit.ly/1qH8tWw )
It opens up Salesforce1 inside Chrome browser. You can use this to see how your app looks inside a mobile device. Tip: You can also debug your app by simply going to https://<instance>.salesforce.com/one/one.app

6. SOQL Tools
There are many tools for you to make and test REST calls and SOQL queries to Salesforce and here are couple of them. 1. Workbench (https://workbench.developerforce.com/login.php (https://workbench.developerforce.com/login.php" target="_blank)) and 2. A Chrome browser plugin called Advanced REST Client ( http://bit.ly/K5yopu (http://bit.ly/K5yopu" target="_blank))

7. Heroku + Canvas App (https://www.heroku.com (https://www.heroku.com" target="_blank)):
If you are planning to build a Heroku + Canvas App, make sure to register to Heroku and setup your Heroku environment.

@rajaraodv (http://twitter.com/rajaraodv" target="_blank)

All of the queries on the sample apps have no Where clauses.  I need to put in a Where clause that limits the query to ownerId= the current user id.

I'm not sure how to capture the current UserId and what that would look like.

 

Here is what I have tried.

 

I edited this function in angular-force.js

            function salesforceSessionRefreshed(creds) {
                // Depending on how we come into this method, `creds` may be callback data from the auth
                // plugin, or an event fired from the plugin.  The data is different between the two.
                var credsData = creds;
                if (creds.data)  // Event sets the `data` object with the auth data.
                    credsData = creds.data;

                SFConfig.client = new forcetk.Client(credsData.clientId, credsData.loginUrl);
                SFConfig.client.setSessionToken(credsData.accessToken, apiVersion, credsData.instanceUrl);
                SFConfig.client.setRefreshToken(credsData.refreshToken);

                //added to get UserID
                var userId = credsData.userId;

                //Set sessionID to angularForce coz profileImages need them
                self.sessionId = SFConfig.client.sessionId;

                callback && callback();
            }

 And then I edited app.js with this where clause, on a custom object.

angular.module('Store', []).factory('Store', function (AngularForceObjectFactory) {
    //Describe the store object
    var objDesc = {
        type: 'Retail_Store__c',
        fields: ['Retailer_Store_Type__c', 'Account_Related_to__r.Name', 'Address_1__c', 'City__c', 'State__c', 'Phone__c',
            'Field_Team_Tier__c', 'Lat__c', 'Long__c', 'Location_Note__c', 'Id'],
        where: 'ownerId='+userId,
        orderBy: 'Account_Related_to__c',
        limit: 20
    };
    var Store = AngularForceObjectFactory(objDesc);

    return Store;
});

 Any Ideas?  Any help is appreciated.

 

  • August 28, 2013
  • Like
  • 0