Questions tagged [pnp-js]

PnPjs is a collection of fluent libraries for consuming SharePoint, Graph, and Office 365 REST APIs in a type-safe way. You can use it within SharePoint Framework, Nodejs, or any JavaScript project.

PnPjs is a collection of fluent libraries for consuming SharePoint, Graph, and Office 365 REST APIs in a type-safe way. You can use it within SharePoint Framework, Nodejs, or any JavaScript project.

Getting Started

Install the library and required dependencies

npm install @pnp/sp --save

Import the library into your application and access the root sp object

import { sp } from "@pnp/sp";
import "@pnp/sp/webs";
import "@pnp/sp/lists";

// get the list by Id
const list = sp.web.lists.getById("03b05ff4-d95d-45ed-841d-3855f77a2483");

// we can use this 'list' variable to execute more queries on the list:
const r = await list.select("Title")();

// show the response from the server
console.log(r.Title);
146 questions
0
votes
0 answers

Using get() when retrieving items with PnP JS Core only return "Undefined" - using items() returns values?

First of all, big shout out to the PnP JS guys and gals - great library that I use constantly! With v2.4.0 I am finding that using the get() call when retrieving items is now returning an "undefined" value, however using the items() call is…
0
votes
1 answer

Is there a reliable way to detect file changes with PnP (nodejs) on Sharepoint?

Im am using PnP nodejs to do certain tasks triggered by SP workflows. To detect whether an uploaded file has changed it's content - I have to retrieve file size or a content hash form the new upload. Unfortunately the item object delivered with…
Oscar
  • 59
  • 1
  • 5
0
votes
1 answer

Sharepoint Online - Read Only User - PnP Modern Search - Unable to get search results

PnP Modern Search Version 3.18 When new user gets created in Office 365 and placed into SharePoint Site's " Visitor" group with only the View Only or Read only access. Search results in the PnP Modern Search results do not show up for that user.…
0
votes
0 answers

Outlook AddIn Taskpane and SharePoint 2019 on-premises

I wants developing a modern Office Add-In for Outlook. This Add-In should support a connection to SP2016, SP2019 and SPO. For these SharePoint-connections I want to use the SP-PNP-JS, but I'm not able to get a SharePoint-context. I'm creating a new…
0
votes
1 answer

How to add pages / web-part zones / web-parts programmatically in SharePoint online using PnP JS?

I have created pages then added web-part zones / web-parts programmatically using below function, function addWebPart(webUrl, pageUrl,webPartXml,zoneId,zoneIndex, Success,Error){ var context = new SP.ClientContext(webUrl); var web =…
0
votes
0 answers

Sharepoint fetchClientFactory is not updating the site url when called multiple time

I have a scenario where I need to fetch lists data from Sharepoint sub sites. My code is something like this. const nodejs_1 = require("@pnp/nodejs"); const sp_1 = require("@pnp/sp"); let sitesArray = ['site1', 'site2', 'site3', 'site4',…
Shafqat Jamil Khan
  • 1,039
  • 1
  • 9
  • 17
0
votes
1 answer

F# and PnP SharePoint

I'm new to F# and trying to recreate some simple apps that I've built in the past with C# or Powershell. I'm trying to get multiple properties for a web. In F#, I can get a single property, but I'm not sure the syntax that would work for getting…
0
votes
2 answers

SharePoint Online - SPFx - How to use GroupBy in PnPjs

I am new to SPFx PnPjs. I want to use GroupBy in query but not seeing intellisense in visual code. Here is my query : var query = pnp.sp.web.lists.getByTitle("Employee").items.select("ID,Title").filter(filterstring).get(); Output i want something…
0
votes
1 answer

CopyTo function issue while copying folder contains files from one library to another Library using pnp js

I am trying to copy the folder from one library to another library. But i am getting an error as below. pnpWebsite.getFolderByServerRelativePath(...).copyTo is not a function TypeError: pnpWebsite.getFolderByServerRelativePath(...).copyTo is not a…
0
votes
2 answers

How to upload image to image column from SharePoint List using REST API(React)

I have a problem of uploading image to image column in sharepoint online via pnpjs I don't know how to convert image and upload to image column in sharepoint list. I tried lot of ways (by convert image to blob, filedata) nothing works. Keep in much…
azarmfa
  • 1
  • 1
  • 2
0
votes
1 answer

How to enable to show dynamically create column in SharePoint default list view

I have created a SharePoint list column using following PNP JS command as below, return pnp.sp.web.lists.getByTitle(this.assessmentHistoryListName).fields.addMultilineText("Favorite", 6, true, false, false, true, { Group: "Custom Columns", Hidden:…
0
votes
2 answers

how to get various lists present in a SharePoint online site in a dropdown for webpart properties spfx

Below is the method which i am using, what i am doing wrong in the below method? Please let me know. private async GetLists(): Promise { console.log("Hitting GetLists Method"); return await …
biggie
  • 5
  • 1
0
votes
1 answer

SharePoint Online Threshold Error after Uploading file and modifying column values (SpFx)

We are facing issue in update of Library column values post upload of file. This issue has started occurring once the record in library exceeded 5,000 items. Please share a code sample which works with library having more than 5,000 items most…
0
votes
1 answer

How do I find out the name from a Principal Id when using pnp sp?

I need to find out the username or name of a principalId number that I'm returning from a REST call which get's role assignments currently on a SharePoint list item. I understand it may involve: const r = await…
NightTom
  • 418
  • 15
  • 37
0
votes
2 answers

SPFX-Chart-webpart-react-pnpcontrol

I am having a spfx webpart where it shows a chart view based on the List selected in property pane. I can able to generate the chart but while changing the list the second chart data shows the prev chart data on hover.The below code is on render…