This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Hit 'ctrl + d' or 'cmd + d' to run the code, view console for results | |
*/ | |
import { spPost, SharePointQueryable } from '@pnp/sp'; | |
import { sp } from "@pnp/sp/presets/all"; | |
const getBody = (siteid, webid, listid, folderid, propertyName, propertyValue) => ` | |
<Request AddExpandoFieldTypeSuffix="true" ApplicationName=".NET Library" LibraryVersion="16.0.0.0" SchemaVersion="15.0.0.0" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"> | |
<Actions> | |
<Method Id="62" Name="SetFieldValue" ObjectPathId="59"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
See: | |
- https://robertschouten.com/2018/04/30/update-file-metadata-with-rest-api-using-validateupdatelistitem-method/ | |
- http://blog.arvosys.com/2018/07/06/list-items-system-update-options-in-sharepoint-online/index.html | |
FieldValues = | |
[ | |
// Text field (single line and note) | |
{ FieldName: "TextField", FieldValue: "123" }, | |
// Number field |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"isFallbackPublicClient": true, | |
"publicClient": { | |
"redirectUris": [ | |
"https://login.microsoftonline.com/common/oauth2/nativeclient" | |
] | |
}, | |
"web": { | |
"implicitGrantSettings": { | |
"enableIdTokenIssuance": false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { sp, SearchResults, SearchQueryInit, ISearchResult } from "@pnp/sp/presets/all"; | |
console.clear(); | |
function parseUserFormattedString(ownerString) { | |
const owners = ownerString.split(";") | |
.map( (owner) => { | |
const parts = owner.trim().split("|"); | |
const oidstr = parts.splice(2,3).join("").trim(); | |
const oids = oidstr.split(" "); | |
return { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { sp, ClientsidePageFromFile, PromotedState, IListItemFormUpdateValue, IClientsidePage, IFileInfo } from "@pnp/sp/presets/all"; | |
console.clear(); | |
function SafeFilename(fileName: string, convertToLower?: boolean): string { | |
const name = (fileName || "") | |
.replace(/[^ a-zA-Z0-9-_]*/gi, "") | |
.replace(/ /gi, "-") | |
.replace(/-*$/gi, "") | |
.replace(/[-]{2,}/gi, "-"); | |
return convertToLower ? name.toLowerCase() : name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { sp } from "@pnp/sp/presets/all"; | |
import "@pnp/sp/taxonomy"; | |
import { taxonomy, ITerm, ITermData } from "@pnp/sp-taxonomy" | |
(async () => { | |
interface ITermDataNode { | |
Id: string; | |
ParentTermId?: string; | |
Name: string; | |
Path: string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
json = [ | |
{ | |
key: 1, | |
id: 1, | |
label: "Parent #1", | |
isexpanded: false, | |
children: [ | |
{ | |
key: 11, | |
id: 11, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { sp } from "@pnp/sp/presets/all"; | |
(async () => { | |
console.clear(); | |
const doPagedQuery = (folder: string, rowLimit: number, scope: "Files"|"Folders", pageToken?: string) => { | |
const list = sp.web.getList('/sites/EDMS_InformationGovernance/Shared%20Documents'); | |
return list.renderListDataAsStream({ | |
ViewXml: ` | |
<View Scope="RecursiveAll"> |