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
1
vote
0 answers

Update app ALM Api in sharepoint site not giving proper response

I have tried updating the apps in sharepoint site using pnp/sp in spfx webpart import { Web } from "@pnp/sp/webs"; public static async UpdateApp(id, web) { var app = web.getAppCatalog().getAppById(id); var response= await app.upgrade(); …
Alias Varghese
  • 2,104
  • 3
  • 24
  • 52
1
vote
1 answer

Getting nested site users in SPFX

I need to find whether current user is a site owner in spfx react . Please find below code which I am using right now const ownerGroupId = (await sp.web.associatedOwnerGroup()).Id const users = await…
Alias Varghese
  • 2,104
  • 3
  • 24
  • 52
1
vote
0 answers

how to display multiple markers simultaneously using the Pnp Map control

I want to display several markers simultaneously on a Map in SPFX WebPart. Is there a way to do this using the Pnp Map Control.
1
vote
1 answer

PnP.js: how to get SharePoint custom lookup column value/title for files under a folder

I have files in SharePoint that have a custom lookup column referencing a list "Document Status". Using PnP.js, I can get the files under a…
user3616544
  • 1,023
  • 1
  • 9
  • 31
1
vote
1 answer

How to tell if a Principal Id is a permission group or a single user?

I'm using pnpJS to list all the users who have permissions on an SPO item: var info = await sp.web.lists.getByTitle('MyList').items.getById(theId2).roleAssignments(); console.log(info, 'info'); var info2 = await…
NightTom
  • 418
  • 15
  • 37
1
vote
1 answer

Getting access denied if a user tries to get role assignments using pnp sp with spfx webpart

I've created a webpart which adds items to a SharePoint list. When the item is submitted I use: var theItem = this.state.Id; console.log(theItem, 'theItem'); const ler2 = await sp.web.lists.ensure("MyList"); const…
NightTom
  • 418
  • 15
  • 37
1
vote
2 answers

Storing current logged in userId in a variable using React SPFx

I am new to SPFx and wrapping my head around getting the current logged in user on SPFx using React , I did refer to a few posts here , However couldn't find the resolution I've been looking for. My end goal is to get the current logged in userID…
Vivek
  • 61
  • 4
  • 16
1
vote
0 answers

You do not have permission to perform this action or access this resource. pnp

We have an portal where an azure AD user will login and will be able to see the data from list on sharepoint. Trying to achieve this using PNPJS and Angular MSAL For the development phase,executed all list operation successfully using sp-rest-proxy…
LearningPal
  • 554
  • 2
  • 12
  • 27
1
vote
1 answer

How to get item ID of the last modified item in the SharePoint online list using pnp powershell?

I am able to get the date of the last modified item in the list using the script below: $SiteURL="https://abc.sharepoint.com/sites/sitename" $ListName="Documents" Connect-PnPOnline -Url $SiteURL -Credentials (Get Credentials) (Get-PnPList…
1
vote
2 answers

Uncaught TypeError: Cannot read property 'map' of undefined on AJAX object

Is there a way that I can pass in N/A as default if there is no results? I want to be able to define it as "N/A" if the mapped object is empty on Title. Some of the items under Media_x0020_Specialist_x0028_s_x.results return, but then some items are…
Tripp
  • 67
  • 6
1
vote
2 answers

How can I check if current user is part of a sharepoint group with PnPJS?

I need to display content based on the group the current user belongs to but can't figure out how to do this in react/pnpjs. I wrote the function below but it returns false even when the group name returned in console.log(grp["Title"]) is…
André Matos
  • 35
  • 1
  • 6
1
vote
1 answer

How can we programmatically generate MS Teams Code

In MS Teams we can manually generate Teams Code and Teams Link which can be used by others to join that Team. Is it possible to programmatically generate this code or link? Any options in PnP (PowerShell or CSOM or JS) or MS graph API? Check this…
1
vote
1 answer

SPFX @pnp/sp v2.0.0 item.like is not a function

I'm using pnpjs v 2.0.0 with SPFX to achieve some list operations. public async getitem(listname) { // get a specific item by id const item: any = await sp.web.lists.getByTitle(listname).items.getById(20).get(); console.log(item); //…
ysfibm
  • 436
  • 2
  • 14
  • 30
1
vote
0 answers

Confused where to look for @pnp full documentation

I'm honestly confused where to find the full documentation of the JavaScript @pnp documentation. According to Microsoft's docs, it's supposed to be at pnp/js. However, I feel the docs are incomplete: Let's say you want to look at how to get a row of…
Andres Biarge
  • 370
  • 4
  • 15
0
votes
0 answers

Using Pnp Modren search webpart how to restrict the search of the users for particular site collection instead of global search to get the results fro

How to restrict the pnP people search to particular site collection instead of global search,so that it can pull the users from that site collection only while searching in the Query temaplate tried Path:"site collection URL" and MemberShipId:0
1
2
3
9 10