8 votes
Accepted

Insert multiple users and groups in a user field of a Sharepoint Online list using Pnp-Js-Core

You can use it as below: $pnp.sp.web.lists.getByTitle("Test").items.add({ Title: "test", MultiUserId: { results: [ 9, 6 ] // User/Groups ids as an array of numbers } }).then(...
user avatar
  • 30.3k
7 votes
Accepted

PnP-JS-Core Property bags

You need to use it as below in typescript: pnp.Web(this.url).select("Title", "AllProperties").expand("AllProperties").get().then(r =>{ console.log(r); }); So pure javascript would be as ...
user avatar
  • 30.3k
7 votes
Accepted

Property 'web' does not exist on type 'SPRest'

In the previous versions 'web' was still present in the rest.d.ts file of the @pnp/sp package. That's not the case anymore. In your main webpart TypeScript file, you have to use the import as follow: ...
user avatar
  • 86
6 votes
Accepted

SPFx - How to get current user properties with PnP-JS-Core

you can use it by doing the following import Web from 'sp-pnp-js'; let web = new Web(this.context.pageContext.site.absoluteUrl); let curruser = web.currentUser.get().then(function(res){ ...
user avatar
  • 1,013
6 votes
Accepted

Can't get context for pnp get api calls in spfx solution

You need to initialize the pnp library with the SPFx context. For that you need to add the below code in your webpart's .ts (TypeScript) file: 1) Add the below import statement import pnp from "sp-...
user avatar
  • 30.3k
5 votes
Accepted

PnPJS with on-prem sharepoint?

It is indeed possible to use PnP JS with SP OnPremise. It supports both 2013 and 2016 as well as the upcoming 2019 environment. Under the hood, it is just a wrapper over the existing REST API ...
user avatar
  • 30.3k
5 votes

PnPJS with on-prem sharepoint?

UPDATE JUNE 2019: Some things were changed in regards to PnPjs library and nodejs integration. Please read below updated guidance on how to use it with on-prem SharePoint and Nodejs: mkdir pnp_test ...
user avatar
5 votes
Accepted

Unable to pull in Number/Lookup Columns using pnp.js

Change this part: table.append(`<td>${item.Title}</td>`); table.append(`<td>${item.Rank}</td>`); table.append(`<td>${item.Franchises}</td>`) to this: table....
user avatar
  • 3,536
5 votes
Accepted

REST API: How to get the n most recent items in ascending order

You will need to do both the REST orderBy, and then use JavaScript to reverse the array of items in the returned results. The problem is thus: In order for the REST API to return only the n most ...
user avatar
  • 3,634
4 votes
Accepted

SPFx - PnP-JS-Core - Check if list exist in current web

You can use the lists.ensure method to check if the list exists or not. Add the below import statement: import pnp, { List, ListEnsureResult } from "sp-pnp-js"; In your method, you can use it as ...
user avatar
  • 30.3k
4 votes
Accepted

Batch operations in SharePoint 2013

No, pnpjs uses the OOTB batching functionality that is not found in SP2013. Depends on what you are doing, but if you need to add a lot of items using JSOM might be your best bet as you can batch ...
user avatar
4 votes

Show loading indicator for any ajax operation via SP PnP JS

You can use the displayLoadingIndicator method available in SPFx. Using it you can show the loading indicator on a DOM element and clear it out using clearLoadingIndicator method once the data is ...
user avatar
  • 30.3k
3 votes

How to perform CRUD Operations on sharepoint lists using React and PnP-JS Core with SharePoint FrameWork (SharePoint 2016)

We have taken multiple initiatives where in we are developing client side web-parts using react for our clients. Traditionally we had been using jquery for making ajax requests in script editors. ...
user avatar
  • 2,376
3 votes

Insert multiple users and groups in a user field of a Sharepoint Online list using Pnp-Js-Core

Check the PnP Js documentation Work with Items here User field will set the value based on the user/group id, very similiar with lookup field: pnp.sp.web.lists.getByTitle("PeopleFields").items.add({ ...
user avatar
  • 2,493
3 votes

How to access to SharePoint Objects (List, ListItem, User, ect) using React and PnP-JS Core with SharePoint FrameWork (SharePoint 2016)

You Will find in the following link all available operations of PnP-JS-Core and how to use them with SharePoint Framework. https://github.com/SharePoint/PnP-JS-Core/wiki/Developer-Guide
user avatar
3 votes
Accepted

SharePoint search refinements filters PnP-JS-Core 2.0.7

You can specify it as below: $pnp.sp.search({ Querytext: "Documents", RowLimit: 10, RefinementFilters : ["and(Author:Gautam,fileExtension:equals('docx'))"] }).then(function(data){ ...
user avatar
  • 30.3k
3 votes
Accepted

Sharepoint Online upload files to library with PnP-JS-Core 2.0.7

You can try the below approach using the FileReader API : Assume that you have html structure somewhat as mentioned below: <input type="file" id="uploadFile" value="Upload File" /> <input ...
user avatar
  • 30.3k
3 votes

SPFx - PnP-JS-Core - Check if list exist in current web

I have tested the PnP List existence check against SP Online. You may try the same with SPFx without SP.SOD <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"> </script&...
user avatar
3 votes
Accepted

SPFX - PnP JS Core for SPFx On-Premise v1.0.2

SPFx for SharePoint 2016 currently uses Typescript 2.1.x. The pnp compatible version for that is version 2.0.8. The latest version 3.0.0 throws some errors because of some breaking changes. To ...
user avatar
  • 30.3k
3 votes

How to make Pnp function async in spfx framework

As i understand your question, you need to handle the response data outside of given function. In this case you can simply return the pnp func call, so it returns a Promise: function ...
user avatar
3 votes

How to make Pnp function async in spfx framework

You need to ensure that your function is async. Only if its async can you use await inside that function. You can modify the below code: private async GetServiceListData():any { var ...
user avatar
  • 30.3k
3 votes

Sharepoint rest GetFileByServerRelativeUrl returns wrong results

For similar ajax calls to SP REST API try use noncache factor on your request url. Example: https://tenant.sharepoint.com/sites/Test/_api/web/getFileByServerRelativeUrl('/sites/Test/Documents/Doc1....
user avatar
3 votes
Accepted

How to upload file in document library using pnp/sp

Looks likely that your document library does not have a Description field, i.e. a field with the internal name "Description". PnP wants you to specify the internal name, not the display name of the ...
user avatar
  • 785
3 votes
Accepted

SharePoint Online Search - Managed Property

Use one of "unused Managed Properties" named Int00 - Int49. https://docs.microsoft.com/en-us/sharepoint/search/manage-the-search-schema#Schema_Tenant_SiteColl_Alias Basic steps: Create a new Site ...
user avatar
3 votes
Accepted

PnP SPFx PeoplePicker control works differently across site collections

This is happening because same user has different user Id in different site (collections). The user Id & information is stored in hidden User Information List at site collection level. You can ...
user avatar
  • 28.2k
2 votes

reference tenant site in config.json

Unfortunately, when referencing external libraries declaratively in config.json, you have to use fixed absolute URLs and there is no way to inject them, unless you would build a custom gulp task. An ...
user avatar
2 votes
Accepted

download file from document library by the help of item ID

You should get it by looking for the EncodedAbsUrl var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('Shared Documents')/items?$select=EncodedAbsUrl&$filter=Id eq ...
user avatar
  • 1,097
2 votes

Sharepoint Framework/PnP-JS/React : state Object doesnt work

Your code tell the TypeScript that the state object is empty object with no members. React.Component accepts two generic types - properties object and state object. You have to change this line ...
user avatar
  • 1,661
2 votes

Trying to update Managed metadata column value in sharepoint library using pnp js

You need to write the values for the fields in quotes. Modify your code as below: pnp.sp.web.lists.getByTitle("ListName").items.getById(1).update({ Title: "Some title", DeptDiv: //internal ...
user avatar
  • 30.3k
2 votes
Accepted

Rest API to update a library item giving 400 error

I finally figured out the issue,i was using the wrong internal name. what i did was to go library setting-->select column-->Have a look at the link and look for field=something. This was the wrong ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible