Skip to content

Instantly share code, notes, and snippets.

View ViewFormattingSample.json
{
"schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
"hideSelection": true,
"hideColumnHeader": true,
"rowFormatter": {
"elmType": "div",
"attributes": {
"class": "sp-row-card"
},
"children": [
View GetTextContent.js
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.target.className === "ms-List-cell" || mutation.target.className === "ms-List-surface") {
var customBody = document.getElementsByClassName('customBody');
for (var i = 0, len = customBody.length | 0; i < len; i = i + 1 | 0) {
var ret;
customBody[i].innerHTML = customBody[i].textContent;
ret = truncate(customBody[i].textContent, 100);
customBody[i].innerText = ret;
@marineko
marineko / OpenFileViaIcon.js
Last active Dec 10, 2019
Open Office document or PDF in new tab via file type icon click on SharePoint library view.
View OpenFileViaIcon.js
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
function getBaseHtml(ctx) {
return SPClientTemplates["_defaultTemplates"].Fields.default.all.all[ctx.CurrentFieldSchema.FieldType][ctx.BaseViewID](ctx);
}
function init() {
var overrideCtx = {};
overrideCtx.Templates = {};
overrideCtx.Templates.Fields = {
'DocIcon': {
View traffic-light.json
{
"$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
"debugMode": true,
"elmType": "div",
"style": {
"height": "10px"
},
"children": [
{
"elmType": "span",
@marineko
marineko / fixHTML.js
Created May 16, 2018
Fix HTML in SharePoint Calculated columns
View fixHTML.js
(function () {
var htmlColumnContext = {};
htmlColumnContext.Templates = {};
htmlColumnContext.Templates.Fields = {
"field1": {
"View": field1ViewTemplate
},
"field2": {
"View": field2ViewTemplate
},
View Description-under-column-name.html
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
<script>
$(document).ready( function () {
$('h3:contains("Body")').parent().append('<p><a href="https://servername/sitename/Doclib/manual.pdf" target="_blank" style="font-weight:normal; text-decoration: underline; color:blue">マニュアルへのリンク</a></p>');
});
</script>
@marineko
marineko / SetLoginUserInfo.js
Last active Mar 28, 2016
Get & Set SharePoint PeoplePicker login user info via REST api.
View SetLoginUserInfo.js
$(document).ready(function () {
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', SetCurrentUserInfo);
});
function SetCurrentUserInfo() {
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties",
contentType: "application/json;odata=verbose",
headers: { "accept": "application/json;odata=verbose" },
success: onSuccess,
@marineko
marineko / GetAllPermission.ps1
Last active Mar 28, 2016
Get all permission assigned to domain group for web, list, folder and item by powershell (SharePoint 2007)
View GetAllPermission.ps1
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
Function UserSource([string]$userName)
{
if($userName.split("\").count -gt 1)
{
$userName.split("\")[0]
}
elseif ($userName.split(":").count -gt 1)
{
$userName.split(":")[0]
View CustomID-EditForm.html
<script src="//code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("input[title='CustomID']").attr("readonly", "readonly").css("color","6a6a6a");
$(":text:not([readonly])").eq(0).focus();
});
</script>
View CreateCustomID.html
<script src="//code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.01/jquery.SPServices.min.js" type="text/javascript"></script>
<script type="text/javascript">
var count;
var itemId;
$(document).ready( function () {
var numStr;
$().SPServices({
operation: "GetListItems",
async: false,