0

I am trying Salesforce chrome plugin for the first time. It is working for me. I was referring one of the existing plugin code found on web and was trying to execute it but I am having issues.

I am using the following in pop.js referred in popup.html. This is used in default_popup in manifest.json file. The following gets called when I click a button on the popup.html. I have included the necessary js files in the popup.html. Looks like my forcetk connection and query not working. I am new to this. Can you please help?:

function init() {
        // Get an instance of the REST API client and set the session ID
        var client = new forcetk.Client();
        client.setSessionToken(getValueFromCookie("sid"));

        // Find cases that belong to the current user
            client.query("select Id from Account Limit 10", function(response){
        console.log('msg posted', response);
        buildResults(response);
            }); 
    }

I am seeing the following error in the console.log:

GET chrome-extension://ajfjakhbbenblfoajmhjlfhajgkheflc/services/proxy?_=1420682846541 net::ERR_FILE_NOT_FOUNDjquery.js:6 x.support.cors.e.crossDomain.sendjquery.js:6 x.extend.ajaxforcetk.js:162 forcetk.Client.ajaxforcetk.js:449 forcetk.Client.querypopup.js:112 initpopup.js:131 (anonymous function)jquery.js:5 x.event.dispatchjquery.js:5 y.handle

0

This will not work until you have a valid session with that Salesforce org I presume you are referring to this piece of code

Read where it says

"In short the code gets the session ID from the user’s cookie (the extension works in the context of the current user session for that tab) and uses that to call in using the REST API. Pretty easy huh?"

If you are logged in to Salesforce and then using the plugin, you should not be getting this issue. Please confirm that if you are logged in already

  • Thank you for a quick reply. I am referring to this code github.com/mwelburn/Chrome-Extension-Force-SOQL-Popup. However I made a minor change to this instead of having message passing from pop-up html and using contentscript.js I am using this in pop.js which is used in popup.html. I have logged into salesforce can see the sid in the browser cookie being present but it is still not working. Is there any sample code I can refer to try out and learn the chrome extension for salesforce? I tried the link you have shared with silverlining.com but that is also not working. – Satvik Jan 8 '15 at 14:47
0

The code is working if I use the code as is from this without modifying the code. : https://github.com/mwelburn/Chrome-Extension-Force-SOQL-Popup

Few things to note: 1) While debugging in the browser we have to refresh the logged-in salesforce instance after we load in the code in the chrome extensions. 2) If there are no records then it appears nothing is working. If the record exists then result is shown. In my org there were no case records so it appeared to me the code is not working. When I modified the code to Account query then result is displayed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.