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
2 answers

How to use fixed urls for images wit PNP Carousel Control for SPFx

I am trying to build a basic Image carousel in SPFx using the PnP Carousel control. Documentation here. I have added the code based on the documentation including the imports and dependancies to set up the carousel but no images appear when I run…
Msco
  • 1
  • 1
0
votes
1 answer

How would I display the Title of each People Picker in this list

I have an SPFX webpart which, when started, it retrieves a list of items from an SPO list and displays them: const Owner = item.OwnerId; var itemOwner = sp.web.getUserById(Owner).select("Title", "Owner/Title").expand("Owner").get().then(r => { …
NightTom
  • 418
  • 15
  • 37
0
votes
0 answers

Initialising spfxContext for a different user in pnp/sp

I'm trying to build an spFx app, that uses a different user to access lists and libraries than the logged in user. The logged in user won't have the permissions to access the lists directly but only via the app. But I can't find a way to initialize…
Romano Zumbé
  • 7,893
  • 4
  • 33
  • 55
0
votes
1 answer

Pnp Js with Sharepoint spfx ListItemPicker

I am using Pnp ListItemPicker for a SharePoint project developed using (SPFx, ReactJs, PnPjs), i am using a SharePoint list called 'Vendor' to populate data into the ListItemPicker (Works without any issues), I am using a sample list called…
0
votes
1 answer

Add AD Groups to Sharepoint Online Group using CSOM

I have the following situation: AD: Users Groups (Type: Security and Office365) Sharepoint: Groups The hole point is to add both the users and the groups from AD to Sharepoint. I got adding the users to work using the following code: User adUser…
JohnRambo
  • 568
  • 1
  • 10
  • 23
0
votes
1 answer

Typeerror : failed to fetch while Uploading file in SharePoint using pnpjs

I have written below code in SPFx Webpart to upload file to Sharepoint Library. It gives me error sometimes like TypeError : Failed to fetch. Can anyone give me some idea what this error signifies and how can it be resolved. function…
0
votes
1 answer

How to use pnp-js at a node.js application to fetch data from sharepoint?

I got a node.js application and I'm trying to use the AdalFetchClient of PnPjs to fetch some data from sharepoint. sp.setup({ sp: { baseUrl: "https://placeholder.sharepoint.com", fetchClientFactory: () => { return new…
0
votes
2 answers

I want to know how to set date value into a Fluent UI datepicker sharepoint spfx react

In here i want to get a date from the SharePoint list and set it in the datepicker, enter image description here FYI the date is coming properly from the API , i am using pnp js to retrieve data, but only the date value is not setting into the…
0
votes
1 answer

How to clear a SharePoint Lookup field with PNP-JS from SPFx WebPart

I have an optional (not-required) Lookup column (Response) in my SharePoint List (Feedback). I am trying to use pnp js to reset the field to nothing. const response = await this.list.items.getById(change.object.id).update({ResponseId: 0}); Looks…
Dennis Kuhn
  • 239
  • 3
  • 10
0
votes
1 answer

Updating total in List and library control

I would like to multiply a numeric field and lookup field upon adding the record. i can do this with normal record (as you see in the case below, where QTY * Item Value is the total. But i would like to multiply the QTY field with…
Rinu
  • 354
  • 2
  • 6
  • 18
0
votes
1 answer

Deploying PnP Provisioning template interactive authorization request error

Ok I an trying to deploy a PnP provisioning template to a site collection. I am running into the following errors and have had no luck so far. This is a more in detail post of my commands and logs. > Connect-PnPOnline -Url "site collection" >…
hittle08
  • 21
  • 5
0
votes
1 answer

How to rename a SharePoint File programaticaly

What is the best way to rename a file in SharePoint online without losing its version history? Is it enough to update the "FileLeafRef" or Should I do a file.move? Is there a Graph way for it?
Ofer Gal
  • 707
  • 1
  • 10
  • 32
0
votes
2 answers

How do I specify list URL when I create it using sharepoint pnp js library?

I am using Sharepoint pnp js library to create a list: https://pnp.github.io/pnpjs/sp/lists/ How do I specify list URL (not title) when creating it? Means, if I want my list URL to look like this (for…
Nikolay
  • 10,752
  • 2
  • 23
  • 51
0
votes
3 answers

PnPJS update items - List data validation failed

We loaded a SP list directly from an Access query and now when we try to run a list update with pnpjs I get an "Error code: -2130575163.List data validation failed" . There are no required fields, no validation on any columns, and no Validation…
Ryan
  • 449
  • 5
  • 21
0
votes
1 answer

How do I fetch items from a specific view(s) of a Sharepoint list in SPFX?

I'm trying to fetch items from a specific view of a Sharepoint list in SPFX using @pnp/sp library but I'm unable to do so. I'm able to fetch the view properties and fields of the list. I didn't find anything as such to fetch the items of that view.…
Aroj Subedi
  • 51
  • 2
  • 5
1 2 3
9
10