Is it possible to retrieve the data from Sharepoint online using Javascript, if we are executing The Javascript outside of the cloud environment. I see that using CSOM SharePointonlineCredentials class is available to connect to office 365. Is there any way using Javascript to connect. And my requirement is to run the script from outside of the cloud network. please suggest.
2 Answers
No.
You would be violating Same-Origin Policy since SharePoint does not expose services through CORS or JSONP.
You would have to use another approach, such as proxy, auto hosted app or sandboxed solution (deprecated).
However if your point is simply to use JavaScript as a language then you access SharePoint through node.js, perhaps with module such as sharepoint-api or node-sharepiont.
If you want to manipulate a list (or web-part) using JS, you can use the JSLink Feature to do that:
1) Simply go to Site Contents of the site that includes the web-part you want to handle with JS and open the Site Assets Library. Upload you JS file there (.js).
2) Then go to the site and Edit it and find the web-part/list of interest. On the upper right side of the web-part click the arrow for the drop-down menu and select Edit Web Part.
3) Now a menu poped up on the right, with Miscellaneous appearing on ist bottom. Expand Miscellaneous and on the JS Link Option enter:
~site/SiteAssets/yourFileName.js
In case you have a question on the JS syntax to retrieve data from the list and handle it, comment and I can edit this answer to include a sample and explaination.
-
My requirement is different. I want to fetch the list data from Sharepoint office 365 site and manipualte as per my requirement. I have written the Script to fetch the data. But this script works if i run it in the Sharepoint environemnt. I want to run that script from my server. So is there any way to authenticate/connect to office 365 to get the list data Commented Feb 12, 2015 at 8:12
-
so you want to access the list items and munipulate them, without connecting to the cloud Server? Commented Feb 12, 2015 at 8:33
-
I'm still not sure of what you want to do exactly, but from what I understood: would exporting an Excel table to the SP Site and creating a read-only Connection to the list (thus list and spreadsheet sync both ways) help? then the spreadsheet updates from the list. You munipulate the list data with JS in the spreadsheet and when you connect to the cloud Server again, it will update the SP list automatically from the spreadsheet. Commented Feb 12, 2015 at 10:42