Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Vadim Gremyachev vgrem

🏠
Working from home
View GitHub Profile
@vgrem
vgrem / RssViewer.xsl
Created Feb 14, 2014
XSL for RSS Viewer web part that demonstrates how to apply formatting
View RssViewer.xsl
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema"
version="1.0" exclude-result-prefixes="xsl ddwrt msxsl rssaggwrt"
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
xmlns:rssaggwrt="http://schemas.microsoft.com/WebParts/v3/rssagg/runtime"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:rssFeed="urn:schemas-microsoft-com:sharepoint:RSSAggregatorWebPart"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:rss1="http://purl.org/rss/1.0/" xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:atom2="http://purl.org/atom/ns#">
View Invoke-RestSPO.Examples.ps1
#Example 1. Gets a value that specifies usage information about the site, including bandwidth, storage, and the number of visits to the site collection
$result = .\Invoke-RestSPO.ps1 -Url "https://contoso.sharepoint.com/_api/site/usage" -UserName "username@tenant.onmicrosoft.com" -Password "password"
write-host 'Total amount of disk space, currently being used by the site collection (Mb):' ([math]::round($result.Usage.Storage /1Mb))
#Example 2. Get List Items
.\Invoke-RestSPO.ps1 -Url "https://contoso.sharepoint.com/_api/web/lists/getbytitle('Contacts')/title" -UserName "username@tenatnt.onmicrosoft.com" -Password "password"
@vgrem
vgrem / PreSave.js
Last active Aug 29, 2015
PreSaveAction function with Email validation
View PreSave.js
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
function PreSaveAction(){
var emailBox = getFieldControl('Email','Text');
if (!validateEmail(emailBox.val())) {
View SPClientForms.ClientValidation.RequiredValidator.js
SPClientForms.ClientValidation.RequiredValidator = function() {
};
SPClientForms.ClientValidation.RequiredValidator.prototype.Validate = function(value) {
value = SPClientTemplates.Utility.Trim(value);
var hasError = value === '';
var errorMsg = hasError ? Strings.STS.L_SPClientRequiredValidatorError : '';
return new SPClientForms.ClientValidation.ValidationResult(hasError, errorMsg);
};
@vgrem
vgrem / PreSaveItem.js
Created Mar 14, 2014
PreSaveItem function
View PreSaveItem.js
function PreSaveItem()
{
if ("function"==typeof(PreSaveAction))
{
return PreSaveAction();
}
return true;
}
@vgrem
vgrem / updateListItem.js
Created Mar 22, 2014
Update operation in SharePoint 2010 REST API
View updateListItem.js
function updateListItem(webUrl,listName,itemId,itemProperties,success, failure)
{
getListItemById(webUrl,listName,itemId,function(item){
$.ajax({
type: 'POST',
url: item.__metadata.uri,
contentType: 'application/json',
processData: false,
headers: {
@vgrem
vgrem / deleteListItem.js
Created Mar 22, 2014
Delete operation in SharePoint 2010 REST
View deleteListItem.js
function deleteListItem(webUrl, listName, itemId, success, failure) {
getListItemById(webUrl,listName,itemId,function(item){
$.ajax({
url: item.__metadata.uri,
type: "POST",
headers: {
"Accept": "application/json;odata=verbose",
"X-Http-Method": "DELETE",
"If-Match": item.__metadata.etag
},
@vgrem
vgrem / SiteLevelStyle.xsl
Created Apr 8, 2014
Level Style for TableOfContents web part
View SiteLevelStyle.xsl
<xsl:stylesheet
version="1.0"
exclude-result-prefixes="x d cmswrt xsl msxsl"
xmlns:x="http://www.w3.org/2001/XMLSchema"
xmlns:d="http://schemas.microsoft.com/sharepoint/dsp"
xmlns:cmswrt="http://schemas.microsoft.com/WebPart/v3/Publishing/runtime"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:template name="node-template">
<xsl:param name="is-horizontal" select="false()" />
View webinfos_addpayload.js
{'parameters': {
'__metadata': {'type': 'SP.WebInfoCreationInformation' },
'Url': 'RestSubWeb',
'Title': 'RestSubWeb',
'Description': 'REST created web',
'Language':1033,
'WebTemplate':'sts',
'UseUniquePermissions':false
}
}
@vgrem
vgrem / ListDataGenerator.php
Last active Aug 29, 2015
The example demonstrates how to generate SharePoint List data from PHP application
View ListDataGenerator.php
<?php
require_once __DIR__ . '/../../Faker/src/autoload.php'; //Faker library (https://github.com/fzaninotto/Faker)
require_once 'SPOClient.php';
$username = 'username@tenant.onmicrosoft.com';
$password = 'password';
$url = "https://tenant.sharepoint.com/";
generateContacts($url,$username,$password);