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(...
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 ...
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:
...
6
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 ...
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){
...
6
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
...
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-...
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....
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 ...
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 ...
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 ...
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 ...
4
votes
Accepted
Unable to resolve "@pnp/graph"' has no exported member named 'graph' in SPFX solution
The use of graph was changed to graphfi in PnPjs v3.
https://pnp.github.io/pnpjs/transition-guide/#global-vs-instance-architecture
Here's a simple example of the use of graphfi from the PnPjs ...
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.
...
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({
...
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
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){
...
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 ...
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&...
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 ...
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 ...
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 ...
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....
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 ...
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 ...
3
votes
Accepted
How to filter the retrieved items using a pnp-js-core REST call to a SharePoint list
You could check the code for this error(SitePages).
If it is caused by this error, you can find the solution here.
https://github.com/SharePoint/PnP-JS-Core/wiki/Using-sp-pnp-js-in-SharePoint-...
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 ...
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 ...
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 ...
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
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
pnp-js-core × 105sharepoint-online × 62
spfx × 44
spfx-webparts × 26
pnp × 18
pnpjs × 12
sharepoint-framework × 11
javascript × 10
typescript × 10
document-library × 7
sharepoint-rest-api × 7
react × 7
sharepoint-enterprise × 5
sharepoint-server × 5
spfx-extensions × 5
office-ui-fabric-react × 4
2013 × 3
jsom × 3
sharepoint-search × 3
office-dev-pnp × 3
list × 2
search × 2
office-365 × 2
2016 × 2
modern-experience × 2