Skip to content

Instantly share code, notes, and snippets.

View rjesh-git's full-sized avatar
🚀

Rajesh Sitaraman rjesh-git

🚀
View GitHub Profile
{
"tenant": "yourtenant.onmicrosoft.com",
"authorityHostUrl": "https://login.windows.net",
"clientId": "89bedb2a-3c1e-4df6-b544-8f1f14392ebd",
"clientSecret": "vM2XycJD8lf29qfckwGC604ATqUBYTFcIsxvdnZuNFo=",
"resource": "https://yourtenant.sharepoint.com"
}
@rjesh-git
rjesh-git / CustomActionPnP-PoweShell.ps1
Created October 31, 2015 15:50
Add custom user action through PnP-PowerShell Cmdlets
Connect-SPOnline –Url https://yoursite.sharepoint.com –Credentials (Get-Credential)
$cUIExtn = "<CommandUIExtension><CommandUIDefinitions><CommandUIDefinition Location=""Ribbon.List.Share.Controls._children""><Button Id=""Ribbon.List.Share.GetItemsCountButton"" Alt=""Get list items count"" Sequence=""11"" Command=""Invoke_GetItemsCountButtonRequest"" LabelText=""Get Items Count"" TemplateAlias=""o1"" Image32by32=""_layouts/15/images/placeholder32x32.png"" Image16by16=""_layouts/15/images/placeholder16x16.png"" /></CommandUIDefinition></CommandUIDefinitions><CommandUIHandlers><CommandUIHandler Command=""Invoke_GetItemsCountButtonRequest"" CommandAction=""javascript: alert('Total items in this list: '+ ctx.TotalListItems);"" EnabledScript=""javascript: function checkEnable() { return (true);} checkEnable();""/></CommandUIHandlers></CommandUIExtension>"
Add-SPOCustomAction -Name 'ff1591d2-8613-4a1c-b465-d647a34b2555-GetItemsCount' -Title 'Invoke GetItemsCount Action' -Description 'Adds custom action to custom l
$cUIExtn = "<CommandUIExtension><CommandUIDefinitions><CommandUIDefinition Location=""Ribbon.List.Share.Controls._children"">
<Button Id=""Ribbon.List.Share.GetItemsCountButton"" Alt=""Get list items count"" Sequence=""11"" Command=""Invoke_GetItemsCountButtonRequest"" LabelText=""Get Items Count"" TemplateAlias=""o1"" Image32by32=""_layouts/15/images/placeholder32x32.png"" Image16by16=""_layouts/15/images/placeholder16x16.png"" />
</CommandUIDefinition></CommandUIDefinitions><CommandUIHandlers>
<CommandUIHandler Command=""Invoke_GetItemsCountButtonRequest"" CommandAction=""javascript: alert('Total items in this list: '+ ctx.TotalListItems);""
EnabledScript=""javascript: function checkEnable() { return (true);} checkEnable();""/></CommandUIHandlers></CommandUIExtension>"
$newUCA = $caColl.Add()
$newUCA.set_registrationId("100");
$newUCA.set_registrationType("List");
$newUCA.set_location('CommandUI.Ribbon');
$rootWeb = $ctx.Web
$ctx.Load($rootWeb)
$caColl = $rootWeb.get_userCustomActions()
$ctx.Load($caColl)
$ctx.ExecuteQuery()
$caColl | ForEach-Object {
if ($_.title -eq 'Invoke GetItemsCount Action') {
$_.DeleteObject()
Write-Host 'Existing item deleted.'
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Publishing.dll"
# Authenticate with the SharePoint site.
#
$siteUrl = Read-Host -Prompt "Enter web url:"
$username = Read-Host -Prompt "Enter Username:"
$password = Read-Host -Prompt "Enter password" -AsSecureString
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
@rjesh-git
rjesh-git / CustomUserAction.ps1
Created October 27, 2015 17:06
Add custom user action through Powershell CSOM
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Publishing.dll"
# Authenticate with the SharePoint site.
#
$siteUrl = Read-Host -Prompt "Enter web url:"
$username = Read-Host -Prompt "Enter Username:"
$password = Read-Host -Prompt "Enter password" -AsSecureString
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
@rjesh-git
rjesh-git / AddUserCustom.ps1
Last active April 8, 2016 01:10
Add UserCustomAction using Powershell CSOM in Office 365
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Publishing.dll"
# Authenticate with the SharePoint site.
#
$siteUrl = Read-Host -Prompt "Enter site url"
$username = Read-Host -Prompt "Enter Username"
$password = Read-Host -Prompt "Enter password" -AsSecureString
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
var aAlert = function() {
alert('hi there');
}
var exportExcel = function () {
var selecteditems = SP.ListOperation.Selection.getSelectedItems();
currentListGuid = SP.ListOperation.Selection.getSelectedList();
var context = SP.ClientContext.get_current();
currentSite = context.get_site();
currentWeb = context.get_web();
var currentList = currentWeb.get_lists().getById(currentListGuid);
@rjesh-git
rjesh-git / sample.js
Last active October 16, 2015 05:27
Passing parameter to localizer.Init()
localizer.Init({
defaultLang: 'fr-FR',
cache: false
});