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

Mocking @pnp/logging in Jest

I'm working in a Spfx project. I have my own Logger class which is a wrapper around the @pnp/logging/Logger. import * as pnpLogging from '@pnp/logging'; export class Logger { public static debug(message: string, notify = false, caller: string =…
Ronald
  • 1,990
  • 6
  • 24
  • 39
0
votes
1 answer

SharePoint online page

Is there a way to get a completely blank sharepoint online page i.e. no command bar, top sharepoint branding etc. I'm not willing to use spfx app customizer as it removes those elements after a delay. Can powershell help here?
explorer
  • 21
  • 7
0
votes
1 answer

How can I create a site using Pnp.core

I am trying to crate a site using . This is the code: using PnP.Framework; TeamSiteCollectionCreationInformation modernteamSiteInfo = new TeamSiteCollectionCreationInformation { Description =…
0
votes
1 answer

Property 'Choices' does not exist on type 'Promise'

I have the following type script inside my ReactJs SPFx sharepoint online web part:- import * as React from 'react'; import * as ReactDom from 'react-dom'; import { Version } from '@microsoft/sp-core-library'; import { IPropertyPaneConfiguration, …
John John
  • 1
  • 72
  • 238
  • 501
0
votes
1 answer

React PNPJs sendemail CC and BCC not working

I have a SharePoint SPFx react web application. I'm using the following link to send emails on actions: https://pnp.github.io/pnpjs/sp/sp-utilities-utility/ My current code looks like this: import { default as pnp, sp, ItemAddResult } from…
JImmy G
  • 149
  • 3
  • 12
0
votes
1 answer

How to find the column type in SPFx?

Does anyone know the best way in SPFx to find the type of a column in a list or document library? I mean if it's a "Single line of text" "Date and Time" "Choice" "Hyperlink or Picture" etc Thanks P
Pete Whelan
  • 85
  • 11
0
votes
1 answer

How to GET/POST SharePoint list/library data out side of SharePoint?

I need to POST data in the SharePoint list from outside of SharePoint. I have created an Angular application and I need to POST data in the SharePoint list using the Angular application with REST API or PnP/JS. Can anyone help me with the…
0
votes
1 answer

How to implement caching in MS Teams Client SPFX Webpart

I am trying to implement caching for a SPFX WebPart using @pnp-Storage. The caching is working alright in the Temas browser but in the Teams client, it isn't working. It is very slow as I have to make multiple azure function call. Can someone please…
0
votes
0 answers

How to get the contents of files in a SharePoint document library using PnP.js and pass them to client application so users can view them

I need to get a list of files from a SharePoint document library and return the results to a client application with file metadata and the contents. I can get the list of files using const files = await…
user3616544
  • 1,023
  • 1
  • 9
  • 31
0
votes
1 answer

How to get sharepoint file custom metadata using PnP.js

Using PnP.js, I can get the files under a folder const files = await sp.web.getFolderByServerRelativeUrl("/sites/mysite/mylib/docs").files.get(); But it doesn't return the custom metadata for the files. It only returns the standard column values…
user3616544
  • 1,023
  • 1
  • 9
  • 31
0
votes
1 answer

Get-PNP**** cmdlets not working even after installing PnP.Powerhsell latest verision

I have installed PowerShell 7 and installed module PnP.PowerShell, when i tab the commands, it is working [Get-Help of the cmdlet (Get-PnPGroupMember) provides the required output], but when i run the script getting following error not…
Vinod kumar G
  • 639
  • 6
  • 17
0
votes
1 answer

Retrieve ID after pushing to SharePoint list using React PNPJs

I'm building a SharePoint SPFx react app. In a nutshell, the user fills out a form that I created. When the user hit's submit, using PNPJs: https://pnp.github.io/pnpjs/sp/items/ I'm adding the item to a list called Request. From there I want to send…
JImmy G
  • 149
  • 3
  • 12
0
votes
1 answer

How to clear PnP PeoplePicker control in SPFx webpart?

I am trying to clear PnP People piker control programmatically in SharePoint online spfx webpart, I am using a simple form with save and cancel button, which save data in List, on the Cancel button I want to clear PeoplePicker value
0
votes
1 answer

Sharepoint site privacy settings though code

I have stressed all morning regarding this minor issue. I have x sharepoint sites, some of them are public some of them are private. I want to be able to modify the privacy settings through code, but so far I have only been able to do it manually. I…
0
votes
2 answers

Hot to retrieve the Sparepoint Guid by given ItemId

I am wondering whether there is way to retrieve the Guid (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) from an given ItemId (eg. ItemID=1969 as in query params in https://xyz.sharepoint.com/path/to/documents/image.jpg?ItemID=1969&ItemVersion=5.0) with…
Oscar
  • 59
  • 1
  • 5