Skip to content

Instantly share code, notes, and snippets.

View phillipharding's full-sized avatar

Phil Harding phillipharding

View GitHub Profile
@phillipharding
phillipharding / Remove .DS_Store files.sh
Created April 28, 2020 16:34
Recursively removes .DS_Store files
## Recursively Remove .DS_Store
# Show
find . -name '.DS_Store' -type f
# Remove
find . -name '.DS_Store' -type f -delete
//import { sp, Site, spGet, SharePointQueryable } from "@pnp/sp/presets/all";
import { sp } from "@pnp/sp";
import { Site } from "@pnp/sp/sites";
import "@pnp/sp/sites";
import { IFetchOptions } from "@pnp/common";
console.clear();
(async () => {
// get site using PnPJs
@phillipharding
phillipharding / SP.MoveCopyUtil.CopyFileByPath.md
Last active July 18, 2022 14:18
SP.MoveCopyUtil.CopyFileByPath()
public async uploadFileToSharePoint(documentLibrary: string, webUrl: string, fileName: string, fileB64: any): Promise <any> {
try {
const web = new Web(webUrl);
documentLibrary = documentLibrary.replace(location.origin, "");
console.log(documentLibrary);
/* const rs: FileAddResult = await web.getFolderByServerRelativeUrl(documentLibrary).files.add(fileName,fileB64,true); */
const rs: FileAddResult = await web.getFolderByServerRelativeUrl(documentLibrary)
.files.addChunked(
fileName,
@phillipharding
phillipharding / Chrome Snippets MBP16.json
Last active January 10, 2020 12:39
To export: let exportSnippets; InspectorFrontendHost.getPreferences(_ => { exportSnippets = JSON.parse(_.scriptSnippets) }); copy(exportSnippets);
importSnippets = [
{
"id": "2",
"name": "Print Display ListForm using Dialog",
"content": "function onListFormPrintViewDialogClosed(dialogResult, returnValue) {\n console.log(\"Print View Dialog closed, result: \" + dialogResult);\n}\n\nfunction showListFormPrintViewDialog(e) {\n e.preventDefault();\n var formUrl = e.data && e.data.url && e.data.url.length ? e.data.url : '';\n if (e.data && (!e.data.url && !e.data.url.length)) {\n /* no url supplied, get the DispForm url for the current listitem form */\n var formCtxName = ($(\"*[id$='ClientFormPlaceholder']\")\n .attr('id')\n .replace(/ClientFormPlaceholder/gi,'')) || \"\";\n var formCtx = window[formCtxName+\"FormCtx\"];\n var listItemId = formCtx && formCtx.ItemAttributes\n ? formCtx.ItemAttributes.Id \n : 0;\n formUrl = formCtx.RedirectInfo\n ? formCtx.RedirectInfo.listRootFolderUrl + \"/DispForm.aspx?ID=\" + listItemId
importSnippets = [
{
"id": "2",
"name": "Print Display ListForm using Dialog",
"content": "function onListFormPrintViewDialogClosed(dialogResult, returnValue) {\n console.log(\"Print View Dialog closed, result: \" + dialogResult);\n}\n\nfunction showListFormPrintViewDialog(e) {\n e.preventDefault();\n var formUrl = e.data && e.data.url && e.data.url.length ? e.data.url : '';\n if (e.data && (!e.data.url && !e.data.url.length)) {\n /* no url supplied, get the DispForm url for the current listitem form */\n var formCtxName = ($(\"*[id$='ClientFormPlaceholder']\")\n .attr('id')\n .replace(/ClientFormPlaceholder/gi,'')) || \"\";\n var formCtx = window[formCtxName+\"FormCtx\"];\n var listItemId = formCtx && formCtx.ItemAttributes\n ? formCtx.ItemAttributes.Id \n : 0;\n formUrl = formCtx.RedirectInfo\n ? formCtx.RedirectInfo.listRootFolderUrl + \"/DispForm.aspx?ID=\" + listItemId
@phillipharding
phillipharding / Get O365 Groups using AdalJS and Graph on Classic SP Page.js
Last active April 1, 2020 14:45
Get Office 365 Groups and Current User Profile using the Graph API and AdalJS to acquire access tokens
console.clear();
/* Logging levels
0: Error
1: Warning
2: Info
3: Verbose
*/
(function() {
/* LOAD ADAL.JS onto the page
@phillipharding
phillipharding / Get Compliance Tags Available for a Site Collection
Created July 17, 2019 09:33
Returns the Office 365 Compliance Tags which have been published to a site collection
POST https://tenant.sharepoint.com/sites/siteurl/_vti_bin/client.svc/ProcessQuery HTTP/1.1
X-RequestDigest: {digest}
Content-Type: text/xml
<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName=".NET Library" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
<Actions>
<StaticMethod TypeId="{9efa17eb-0d34-4f69-a085-5cc3f802439e}" Name="GetAvailableTagsForSite" Id="22">
<Parameters>
<Parameter Type="String">https://tenant.sharepoint.com/sites/siteurl</Parameter>
</Parameters>
@phillipharding
phillipharding / Get Term By Id from Group and Termset by Name
Created June 10, 2019 16:21
Get a Term by its ID with LocalCustomProperties from a Termgroup and Termstore by Name
POST https://platinumdogsconsulting.sharepoint.com/teams/PKC_EDMS_Discovery/_vti_bin/client.svc/ProcessQuery
Content-Type: text/xml
X-RequestDigest:
User-Agent:
Host:
<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>
<ObjectPath Id="48" ObjectPathId="47"/>
<ObjectIdentityQuery Id="49" ObjectPathId="47"/>