Skip to main content

Posts

Showing posts with the label SharePoint 2013

Populate people picker field with logged in user in SharePoint using JS

Please use below code to populate people picker in SharePoint online, <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type="text/javascript"> ExecuteOrDelayUntilScriptLoaded(function () { setTimeout(function () { SetUserFieldValue('AuthorName'); }, 1000); }, 'clientpeoplepicker.js'); //Set PeoplePicker Value function SetUserFieldValue(fieldName) { try{ var userAccountName = _spPageContextInfo.userLoginName; //PeoplePicker Object var peoplePicker = $("div[title='" + fieldName + "']"); //PeoplePicker ID var peoplePickerTopId = peoplePicker.attr('id'); //People PickerEditor var peoplePickerEditor = $("input[title='" + fieldName + "']"); //Set Value to Editor peoplePickerEditor.val(userAccountName); //Get Client PeoplePicker Dict var peoplePickerObject = SPClientPeoplePicke...

Show modified by author and date in all pages in O365 SharePoint site

Show modified by author and date in all pages in O365 SharePoint site using below script, $(document).ready(function() { GetEditorAndDate(); });  // end document-ready function GetEditorAndDate() { var relativePageURL = _spPageContextInfo.serverRequestPath; var siteURL = _spPageContextInfo.webAbsoluteUrl; var profileUrl = "https://myorg.sharepoint.com/sites/devsite/"; var query = siteURL + "/_api/web/getfilebyserverrelativeurl('/"+ relativePageURL +"')?$select=TimeLastModified,ModifiedBy/Title,ModifiedBy/LoginName&$expand=ModifiedBy"; var call = $.ajax({ url: query, type: "GET", dataType: "json", headers: { Accept: "application/json;odata=verbose" }     }); call.done( (function (data, textStatus, err){  rawModifedBy = data.d.ModifiedBy.Title  prettiedModifiedBy = rawModifedBy.split(', ')[1]+' '+ rawModifedBy.split(', ')[0]  rawModi...

How to delete duplicates from SharePoint list using JSOM

How to delete duplicates from SharePoint list using JSOM, Credit: Thulasi Pasam Reference:  https://community.nintex.com/thread/8516 Note: Make sure the reference file paths Make sure the column to test duplicate on CAML query Update your SharePoint list name <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="X-UA-Compatible" content="IE=5, IE=8, IE=9, IE=10" > </head> <body> <div Id="myDiv" style= "width: 75%;"> <table id="tblHeading"  width = "100%" align = "left"> <tr style ="width:100%;"> <td><input type= "button" onclick="Delete()" align = "Center" alt="Delete Duplicates" value="Delete...

Bind a html string with Enhanced rich text box which has heavy formatting in O365 using Angular JS

Bind a html string with Enhanced rich text box which has heavy formatting in O365 using Angular JS , below solution did the trick. You have to use  $sce.trustAsHtml() , to use it directly into the DOM, you could do it like this, JS/controller part: Ref:  http://stackoverflow.com/questions/21503588/angularjs-bind-html-string-with-custom-style $scope . trustAsHtml = function ( string ) { return $sce . trustAsHtml ( string ); }; And in DOM/HTML part <div data-ng-bind-html = "trustAsHtml(htmlString)" ></div>

Delete a particular web part from all the sites ans sub sites

Please us below PowerShell script to delete a particular web part from all the sites ans sub sites, Add-PSSnapin "Microsoft.SharePoint.PowerShell" #$CSVFile = Import-CSV -Path "E:\Ulhas\Subsites.csv" $filepath = "E:\Ulhas\Subsites.csv" Import-CSV $filepath -Header SiteUrl | Foreach-Object{     $SPweb = Get-SPWeb $_.SiteUrl #"https://www.contoso.com/it/pmo/"     $webpartmanager = $SPweb.GetLimitedWebPartManager(($SPweb.Url + "default.aspx"),  [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)        $webpartsarray = @()      For($i=0;$i -lt $webpartmanager.WebParts.Count;$i++)       {         if($webpartmanager.WebParts[$i].title -eq "ScriptToRemoveBlankSpace")  #Check for particular web part          {           $webpartsarray = $webpartsarray + $webpartmanager.WebParts[$i].ID        ...

Permission audit report for site and all sub sites using PowerShell

Use below script to get Permission audit report for site and all sub sites using PowerShell, Add-PSSnapin "Microsoft.SharePoint.PowerShell" $URL="https://intranet.contoso.com/sales/mysite/"      $site = Get-SPSite $URL      #Write the Header to "Tab Separated Text File"         "Site Name`t  URL `t Group Name `t User Account `t User Name `t E-Mail" | out-file "E:\Ulhas\UsersandGroupsRpt.txt"          #Iterate through all Webs       foreach ($web in $site.AllWebs)       {         #Write the Header to "Tab Separated Text File"         "$($web.title) `t $($web.URL) `t  `t  `t `t " | out-file "E:\Ulhas\UsersandGroupsRpt.txt" -append          #Get all Groups and Iterate through            foreach ($group in $Web.groups)         ...

Color coding the list status column in SharePoint 2013

Below formula can be used to color code the list status column in SharePoint 2013, ="<DIV style='font-weight:bold; font-size:42px; color:"&CHOOSE(RIGHT(LEFT(Priority,2),1),"red","orange","green")&";'>•</DIV>" Credit goes to Junaid Khan here:  https://junaidsk.wordpress.com/2014/02/25/color-coding-in-sharepoint-lists-using-calculated-columns/

Hide top navigation and quick launch in SharePoint 2013

Hide top navigation and quick launch in SharePoint 2013, < style type = "text/css" > .main-topbar , #siteIcon , .search-area , #s4-titlerow , #sideNavBox {display:none !important;} #contentBox {     margin-left: 0; } div #s4-ribbonrow {     height: auto !important;     margin: 0; } #ActionDiv a {     background: #f1f1f1 none repeat scroll 0 0;     border: 1px solid #ccc;     display: inline-block;     margin-bottom: 5px;     margin-right: 4px;     padding: 3px 8px !important;     text-align: center; } #ActionDiv {     text-align: left; } </ style > Hope this helps!!!

Article page showing HTML tags in SharePoint 2013

Article page showing HTML tags, use below PowerShell to fix as mentioned here : http://labs.steveottenad.com/publishing-columns-show-escaped-html-in-sharepoint-2010/ Add-PSSnapin "Microsoft.SharePoint.PowerShell" $web = Get-SPWeb "https://contoso.com/sites/mysite/it/" $list = $web.GetPublishingPages(); foreach ($page in $list.Items) {     if ($page.Title -eq "Testing123")     {         [Microsoft.SharePoint.Publishing.Fields.HtmlField]$field = [Microsoft.SharePoint.Publishing.Fields.HtmlField]$list.Fields[“Page Content”]         $field.RichText = $true         $field.RichTextMode = [Microsoft.SharePoint.SPRichTextMode]::FullHtml         $field.Update()         break;     } } $list.Update() $web.dispose() Hope this helps!!!

How to move list paging in top right corner in SharePoint 2013

Add script editor web part and paste the below code to move list paging in top right corner in SharePoint 2013, < script type = "text/javascript" > $ ( document ).ready( function () {   var header = $ ( "table.ms-listviewtable" );   var table = $ ( "#bottomPagingCellWPQ3" );     if (header & & table)     {         table. insertBefore (header);         $ ( "#bottomPagingCellWPQ3" ).css( 'text-align' , 'right' );     }     else     {         alert ( 'jQuery did not found Elements.' );     } }); </ script > < style type = "text/css" > td #bottomPagingCellWPQ3 {float:right} </ style > Hope this helps!!!

Apply page layout for a particular page in SharePoint 2013 using PowerShell

In this article we will see how to apply page layout for a particular page in SharePoint 2013 using PowerShell, $spWeb = Get-SPWeb("https://server.com/sites/MyWeb") $spFile = $spWeb.GetFile("https://server.com/sites/Pages/MyPage.aspx") $spFile.CheckOut("Online",$null) $spFile.Properties["PublishingPageLayout"] = "/sites/_catalogs/masterpage/PageLayout.aspx" $spFile.Update() $spFile.CheckIn("Update page layout via PowerShell",[Microsoft.SharePoint.SPCheckinType]::MajorCheckIn) $spWeb.Dispose() Hope this helps!

Migrated content verification from MOSS 2007 to SharePoint 2010/2013

The below links may help for migration/upgrade of SharePoint environment, http://community.rightpoint.com/blogs/viewpoint/archive/2015/03/29/create-and-compare-a-source-and-target-site-inventory-using-powershell.aspx http://www.sharepointpals.com/post/Activities-to-be-performed-before-Upgrade-Migrate-from-SharePoint-2010-to-SharePoint-2013 Upgrade Worksheet from MS-  http://www.microsoft.com/en-us/download/details.aspx?id=30370

PowerShell to continue from catch block if there is an error

Below code snippet will help you to continue from catch block if there is error, try{ [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")| Out-Null $Site = new-Object Microsoft.SharePoint.SPSite($siteCollUrl) $alertResultsCollection = @() $a = $ErrorActionPreference  $ErrorActionPreference = "SilentlyContinue" foreach($SiteColl in $Site.WebApplication.Sites) { if($SiteColl -ne $null) { Write-Host "Processing site " $SiteColl.URL Try{                 foreach ($web in $SiteColl.AllWebs)  { if($web -ne $null) { Try{ foreach ($alert in $web.Alerts) {                                             $alertURL = $web.URL + "/" $alertResult = New-Object PSObject $alertResult | Add-Member -type NoteProperty -...

Imporant technical help links for SharePoint 2013 Development

1. Expand & Collapse Content Query Webpart  http://social.technet.microsoft.com/Forums/en-US/7d601e67-8957-42a8-abfb-7cbcc61b1c24/expandcollapse-groups-in-content-query-web-part-in-sharepoint-2010?forum=sharepointcustomizationprevious http://social.msdn.microsoft.com/Forums/en-US/c15fe870-76e6-4a11-b5bd-e70110be41a8/collapse-groups-in-content-query-web-part http://store.bamboosolutions.com/sharepoint-data-viewer-web-part.aspx (using bamboo chart API) 2. Adding alias name to Sharepoint site http://social.technet.microsoft.com/Forums/sharepoint/en-US/b76cf17d-85cb-4a5e-9f7b-e0efdf438667/add-alias-url-for-a-sharepoint-site?forum=sharepointadminlegacy http://www.mssharepointtips.com/tip.asp?id=929&page=1 http://www.mssharepointtips.com/tip.asp?id=1102&page=2 3. Backing up and restoring Sharepoint site http://office.microsoft.com/en-in/windows-sharepoint-services-it/backing-up-and-restoring-web-sites-HA001160826.aspx http://www.sharepoint-journey.com/backup-and-restore...