spscript
TypeScript icon, indicating that this package has built-in type declarations

5.1.1 • Public • Published

SPScript


Join the chat at https://gitter.im/DroopyTersen/spscript

Visit https://spcript.com for full documentation.

SPScript is a collection of javascript helpers for the SharePoint Rest API. Some features include...

  • Easy querying of list data.
  • Add and Update list items in 1 line of code.
  • Easily utilize SharePoint search
  • Work with the Profile Service
  • Check permissions on sites and lists
  • Work with CustomActions

Installation

Add the SPScript npm package to your project

NPM

npm install spscript

Yarn

yarn add spscript

Importing

You can use SPScript in your Javascript/Typescript files with:

import SPScript from "spscript";

ProTip: Dynamically/Temporarily add SPScript to a Modern page with Dev Tools

You can enter the following into a browser console to dynamically load SPScript on a page.

let script = document.createElement("script");
script.src = "https://unpkg.com/spscript@beta/dist/spscript.browser.js";
document.head.appendChild(script);

SPScript Context

Almost everything in SPScript is based off an SPScript Context class.

  • An SPScript Context is tied to specific SharePoint site.
  • You get a Context by calling SPScript.createContext(siteUrl).

You get a Context by calling SPScript.createContext(siteUrl).

This line of code is the entry point to almost everything SPScript provides.

let ctx = SPScript.createContext(siteUrl);

Example Usage: Get the News Pages of the specified site.

import SPScript from "spscript";
 
const getPublishedNews = async function (siteUrl) {
  let ctx = SPScript.createContext(siteUrl);
  let pages = await ctx.lists("Site Pages").findItems("PromotedState", 2);
  console.log(pages); // This will show an Array of Page List Items
  return pages;
};

Throughout the docs you'll see a variable, ctx, representing an instance of an SPScript Context.

Troubleshooting

If you are using Typescript, you may have to use the syntax:

import * as SPScript from "spscript";

If you don't like that, add "allowSyntheticDefaultImports": true to your tsconfig.json.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
5.0.0-beta.732beta
5.1.115latest

Version History

VersionDownloads (Last 7 Days)Published
5.1.115
5.0.00
5.0.0-beta.732
5.0.0-beta.60
5.0.0-beta.40
5.0.0-beta.30
5.0.0-beta.10
5.0.0-beta.00
4.2.00
4.1.20
4.1.10
4.1.00
4.0.51
4.0.40
4.0.30
4.0.20
4.0.10
4.0.00
4.0.0-00
3.1.01
3.0.9-beta0
3.0.8-beta0
3.0.7-beta2
3.0.6-beta0
3.0.5-beta0
3.0.4-beta0
3.0.3-beta0
3.0.2-beta0
2.0.51
2.0.40
2.0.30
2.0.20
2.0.10
2.0.01
1.7.00
1.6.00
1.5.10
1.5.00
1.4.30
1.4.20
1.4.10
1.4.00
1.3.60
1.3.50
1.3.40
1.3.20
1.3.10
1.3.00
1.2.50
1.2.41
1.2.30
1.2.20
1.2.10
1.2.00
1.1.80
1.1.70
1.1.60
1.1.50
1.1.40
1.1.30
1.1.20
1.1.10
1.1.00
1.0.10
1.0.00

Package Sidebar

Install

npm i spscript

Weekly Downloads

54

Version

5.1.1

License

none

Unpacked Size

288 kB

Total Files

76

Last publish

Collaborators

  • droopytersen