Client Object model and Rest API-JavaScript Apps (1)

To create apps using Visual Studio 2015 Community, you need to make sure create sharepoint teamsite as developer site. We should make apps on developer site, then it need to deploy to app store. If you use not developer site but teamsite, on debugging , you can meet error as “Error occurred in deployment step “Install SharePoint-Add in’ : Sideloading of apps is not enabled on this site.”

Today I’ll show how to create javascript apps on online sharepoint

Create new project on visual studio 2015 communtiy

  1. Open Visual Studio 2015 community as administrator
  2. Make new project , select to Office Add-ins as “SharePoint Add-In” as name of JavaScriptDemo2createnewproject
  3. You need to input “What SharePoint site do you want to use for debugging your add-in?” to sharepoint developer site, and also select “SharePoint-hosted”newSharePointAddIn
  4. You need to select “SharePoint Online” on the Specify the target SharePoint versionspecifiyTheTargetSP
  5. It creates “JavaScriptDemo2” project as automatically

See around project which you created.

You can see Default.aspx page , it have SharePoint Script as “sp.js” , jquery and app.js.

Let me explain those components.

SP.ClientContext object (sp.js) : Represents the context for objects and operations.ClientContext constructor  initializes a new instance of the ClientContext object for the specified SharePoint site.

app.js : you can add javascript code and jquery code also

Let’s do it as easy example.

Create button on Default.aspx as Html Tag inputButton

Move to App.js then remove all scripts except ‘use strict’ on top of this script.appJsSc

After you save all changes then you need to “Execute” Button on Visual Studio, you can see deployed apps on this sharepoint like below. defaultPage

If you click “Load” Button, you can show below site as changed to message as “JavaScriptDemo1”AfterClickButton.png

This post which I recently uploaded to this blog to study online sharepoint as client object model. Since now I’ll create and concentrate on online sharepoint development

 

텐서 플로우 블로그 (Tensor ≈ Blog)

머신러닝(Machine Learning), 딥러닝(Deep Learning) 그리고 텐서(Tensor) 또 파이썬(Python)

Jaap Wesselius

Microsoft UC Specialist

Office365 Cloud for My site

Office365 & SharePoint & PowerShell