Skip to content

Instantly share code, notes, and snippets.

Phil Harding phillipharding

Block or report user

Report or block phillipharding

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View UploadFileToSharePoint.ts
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 Jan 10, 2020
To export: let exportSnippets; InspectorFrontendHost.getPreferences(_ => { exportSnippets = JSON.parse(_.scriptSnippets) }); copy(exportSnippets);
View Chrome Snippets MBP16.json
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
View Chrome Snippets MBP16.json
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
View SharePoint 2013 Content Editor WebPart.xml
<WebPart xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/WebPart/v2">
<Title>House-Rules-Info</Title>
<FrameType>None</FrameType>
<Description></Description>
<IsIncluded>true</IsIncluded>
<FrameState>Normal</FrameState>
<MissingAssembly>Cannot import this Web Part.</MissingAssembly>
<PartImageLarge>/_layouts/15/images/mscontl.gif</PartImageLarge>
<IsIncludedFilter />
<Assembly>Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
@phillipharding
phillipharding / Get O365 Groups using AdalJS and Graph on Classic SP Page.js
Last active Oct 10, 2019
Get Office 365 Groups and Current User Profile using the Graph API and AdalJS to acquire access tokens
View Get O365 Groups using AdalJS and Graph on Classic SP Page.js
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 Jul 17, 2019
Returns the Office 365 Compliance Tags which have been published to a site collection
View Get Compliance Tags Available for 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 Jun 10, 2019
Get a Term by its ID with LocalCustomProperties from a Termgroup and Termstore by Name
View Get Term By Id from Group and Termset 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"/>
View Chrome Snippets MBP13.json
[
{
"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\n
@phillipharding
phillipharding / CreateListItemInAnotherSite.js
Created May 30, 2019
Create a ListItem in another site using the REST API
View CreateListItemInAnotherSite.js
(async function() {
function getFailedResponseData(response) {
return new Promise( async (resolve) => {
const ct = response.headers.get("Content-Type") || "";
let data = {};
if (ct.match("application/json")) {
data = await response.json();
} else {
You can’t perform that action at this time.