Skip to content

Instantly share code, notes, and snippets.

View ktskumar's full-sized avatar

Shantha Kumar T ktskumar

View GitHub Profile
@ktskumar
ktskumar / SyncFlowInstances.js
Created June 6, 2021 05:29
Retrieves the Flow instances associated to the SharePoint List using REST API
/* **** RUN THIS SNIPPET in Browser Developer Console to see the output **** */
// POST request Call
function RestRequest(url, params) {
var req = new XMLHttpRequest();
return new Promise(function(resolve, reject) {
req.onreadystatechange = function() {
if (req.readyState != 4) // Loaded
return;
if (req.status >= 200 && req.status < 300) {
resolve(req);
@ktskumar
ktskumar / getspcurrentuser.js
Last active July 7, 2023 13:58
Retrieve the Current User information from SharePoint
//getRequest method reference
//https://gist.github.com/ktskumar/a9e9df497673e9fd26ead8532b9ff425
//Returns the current user information
getRequest("https://domain.sharepoint.com/sites/name/_api/web/currentuser").then(function(output){
console.log(JSON.parse(output.response));
});
//Returned Properties
//Email, Expiration, Id, IsEmailAuthenticatonGuestUser, IsHiddenInUI, IsShareByEmailGuestUser, IsSiteAdmin, LoginName,
@ktskumar
ktskumar / updateWriteSecurity.js
Created November 30, 2021 07:19
Change Item Level permission for SitePages Library
//Update the WriteSecurity to change the item level permissions
//Set the Edit property to Create items and edit items that were created by the user
// 1 - Create and edit all items
// 2 - Create items and edit items that were created by the user
// 3 - None
import { sp, Web } from "@pnp/sp/presets/all";
(async () => {
@ktskumar
ktskumar / voice_validation.html
Last active June 13, 2022 23:40
Voice recognition and validation by comparing two speecs and determine if they are from the same speaker. Try it with your own voice!
<!DOCTYPE html>
<html>
<head>
<title>Speaker Authenticator</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/recorderjs/0.1.0/recorder.js"></script>
</head>
<body>
<div class="container">
<h1>Validate Speaker</h1>
@ktskumar
ktskumar / copy-webpart.ts
Created March 8, 2022 00:20
Copy web-part from one page to another modern page in SharePoint
/*
Below code uses the PnP JS and helps to copy the webpart from one page to another page in modern SharePoint page
*/
import { sp } from "@pnp/sp/presets/all";
(async () => {
const page = await sp.web.loadClientsidePage("/sites/portal/SitePages/page2.aspx");
const control = page.sections[1].columns[0].getControl(0);
@ktskumar
ktskumar / mgt-showgroups.html
Created December 17, 2021 10:52
HTML snippet for render groups in a responsive table
<mgt-get resource="/groups" version="v1.0" scopes="group.read" max-pages="2">
<template>
<div class="get-wrapper">
<div class="table">
<div class="row header">
<div class="cell">
Name
</div>
<div class="cell">
Email
@ktskumar
ktskumar / mgt-explorejson.html
Created December 16, 2021 14:28
Explore JSON response from mgt-get
<mgt-get resource="/me/drive" version="v1.0" scopes="file.read" max-pages="2">
<template>
<div class="objcontainer" data-for="{{a in Object.keys(this)}}">
<div class="key">{{a}}</div>
<div data-if="{{typeof(this[a]) != 'object'}}" class="value">{{this[a]}} </div>
<div data-else class="value">
<div data-for="{{b in Object.keys(this[a])}}">
<div class="key">{{b}}</div>
<div class="value">{{this[a][b]}}</div>
</div>
@ktskumar
ktskumar / mgt-profileanimation.html
Created December 7, 2021 01:41
Animate Profile using Microsoft Graph Toolkit
<mgt-person person-query="me">
<template>
<div id="outerContainer" data-if="person.personImage">
<div id="container">
<div class="item">
<img src="{{ person.personImage }}" />
</div>
<div class="circle" style="animation-delay: -3s">
</div>
<div class="circle" style="animation-delay: -2s">
@ktskumar
ktskumar / spfx-mgt-showemails.htm
Created November 30, 2021 00:46
Display Recent Mails using Microsoft Graph Toolkit
<mgt-get resource="/me/messages" version="beta" scopes="mail.read" max-pages="2">
<template>
<div style="background-color:#eee;padding:8px 30px;">
<div class="email" data-for="email in value" style="padding:20px; background-color:#fff">
<h3>{{ email.subject }}</h3>
<h4>
<mgt-person person-query="{{email.sender.emailAddress.address}}" view="oneline" person-card="hover">
</mgt-person>
</h4>
<div data-if="email.bodyPreview" class="preview" innerHtml>{{email.bodyPreview}}</div>
@ktskumar
ktskumar / spHideSearchBoxinNavBar.js
Created June 17, 2021 18:02
Code helps to hide the searchbox in navbar in SharePoint Site
// POST request Call
function RestRequest(url, params) {
var req = new XMLHttpRequest();
return new Promise(function(resolve, reject) {
req.onreadystatechange = function() {
if (req.readyState != 4) // Loaded
return;
if (req.status >= 200 && req.status < 300) {
resolve(req);
} else {