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
1 answer

A way to fetch Microsoft Graph locations with PnPJs

As stated above in the title I am currently facing issues fetching graph places with PnPJs, using the @pnp/graph graphfi factory interface in SPFx. I am currently able to fetch data from my events via graphfi as can be seen below: React.useEffect(()…
0
votes
0 answers

How to properly upload multiple attachments to sharepoint using pnpjs?

I need the users to be able to upload attachments. then i need to display the attachment so it can be selected and viewed. sometimes there may only be a single attachment. sometimes multiple. file type can be .xlsx,.xls,.doc, .docx,.ppt,…
0
votes
1 answer

How Can I See all Of The Available Additional Identifiers For A SharePoint Column

Sorry for the weird question as I am really just learning SharePoint and do not know the best vernacular. at work, we have code that accesses a sharepoint list item, then selects and expands the columns so that we can use the data in those…
0
votes
0 answers

How to use pnp/spfx controls people picker with functional react and no this keyword in my sharepoint project?

I need to use this pnp/spfx people picker in my functional based react project. https://pnp.github.io/sp-dev-fx-controls-react/controls/PeoplePicker/ But all of the tutorials and images across the web are explaining usage within a class based react…
0
votes
0 answers

Retrieve Sharepoint items with pnpjs ListItemPicker component

I'm working with Pnpjs ListItemPicker component and I'm fetching items related to a specific listId. Since the get() call only allows me to retrieve a hundred items, there is some configuration option that can be used to bypass the…
Marco
  • 1
0
votes
1 answer

It is possible to retrieve more than 100 list items Sharepoint with ListItemPicker component?

I'm working with SPFx framework and I'm trying to get all the list items correlated to a specific list. More in details, in my code, I'm using the get() method to retrieve the items, but this function give me only the first 100 elements. This is the…
Marco
  • 1
0
votes
0 answers

remove sharepoint metadata from ms office documents programmatically in JS

I'm facing the issue when uploading to SP file which was previously downloaded from there. Metadata fields are getting populated, which I should void. In fact, I'm trying to replace file, using this method from pnpjs- await…
0
votes
1 answer

Shuffle the results coming back from getItemsByCAMLQuery

In my SPFx web part below I get items from a list. That works fine. What is the best way to randomise the results that come back? I tried to do r = r.shuffle(); but I think I am way off. Thanks P if(typeof this.properties.filterByPosition…
Pete Whelan
  • 85
  • 11
0
votes
0 answers

PnP Core SDK - Get Roles of SharePoint default groups and make them OnlyView

Currently trying to implement the behaviour to change the roles for the default Groups in Sharepoint (Owner, Member, Viewer). Goal is to set the Member roles to only "view". I found this Documentation. My Code: await pnpContext.Web.LoadAsync(p =>…
0
votes
1 answer

PnP Core .Net Access subfolder inside my Documents Folder in SharePoint

Currently implementing Code to Access a specific Folder called "Customer" which is inside my Documents Folder in Sharepoint. Whatever I tried it wont work.. var list = await pnpContext.Web.Lists.GetByTitleAsync("Documents", p => p.RootFolder, …
0
votes
1 answer

call SharePoint's add new webpart function from within a web part component (spfx-reactjs)

I'm just new to reactjs-spfx controls. I have a pnpjs control that lists all the pages and it's contents. I should be able to add edit and delete pages using that web part. I want to include in that component the functionality to add a new Web part…
Sol
  • 53
  • 7
0
votes
0 answers

@pnp/sp list request returns different objects on SharePoint Site view/edit mode

I use the @pnp/sp library to get list data in a SPFX web part. The crucial code for my issue looks as follows: const list = await sp.web.lists .getByTitle("ListTitle") .fields.getByTitle("Category") .get(); return…
IngoH
  • 159
  • 7
0
votes
1 answer

PNP CustomCollectionFieldType - PeoplePicker can't find users

As the title states I am trying to use the PropertyFieldCollectionData in my SPFx Property Pane. But when I run the code and try to search in the peoplepicker nothing shows up, not even myself. Don't know if it would be of any help but here is the…
0
votes
1 answer

Getting attachments from a list in SPO (SPFx) is taking a long time

I have a web part in SPFx for SharePoint Online which displays list items and any attachments on those list items. The code seems to take quite a while (maybe a third of a second per attachment) Is there any way to speed things up? Thanks P …
Pete Whelan
  • 85
  • 11
0
votes
1 answer

Sharepoint Framework SPFx - Pnp/PnPjs with React - Taxonomy Picker not working

I have created the SPfx project with React. I have used @pnp/sp": "^3.. for interaction with SharePoint. I can successfully get data from the SharePoint lists and Libraries. Now, I need to get SharePoint taxonomy terms and it's the parent term of…