Skip to main content

Posts

Showing posts from 2016

SharePoint 2013 - Send Email With Attachment

https://spworkflowactions.codeplex.com/

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"

Show confirmation message on click of save in OOB list forms in SharePoint

Show confirmation message on click of save in OOB list forms in SharePoint, add the below script in each OOB list form page. <script type="text/javascript" language="javascript" src="/sites/dev/Style%20Library/Scripts/jquery-3.1.0.min.js"></script> <script type="text/javascript"> function PreSaveAction() {   if($('[id*="Update"]').is(':checked')){ return (confirm("This item has value of Update as “Yes”. Are you sure you want to save this item?")); } else{ return true; } } </script>

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>

GetListItem and UpdateListItem using SPServices in MOSS 2007

GetListItem and UpdateListItem using SPServices in MOSS 2007 $(document).ready(function() { var itemToUpdate = GetListItem(); UpdateListItem(itemToUpdate); }); function GetListItem(){ var today = new Date(); var dayOfWeek = today.getDay(); var itemID = 0; var out = ""; var titleField = "<FieldRef Name='Title' />"; var descriptionField = "<FieldRef Name='Description' />"; var viewFields = "<ViewFields>" + titleField + descriptionField + "</ViewFields>"; var myQuery = "<Query>" + "<OrderBy>" + "<FieldRef Name='ItemOrder' Ascending='True'/>" + "</OrderBy>" + "</Query>"; $().SPServices({ operation: "GetListItems", async: false, listName: "MyList", CAMLQuery: myQuery,   CAMLViewFields: viewFields, completefunc: fun

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              }       }      $var=$webpartsarray.length      write-host $var      for($j=0; $j -lt $var; $j++)

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)          {                 "`t  `t $($Group.Name) `t   `t `t " | out-file "E:\Ulhas\UsersandGroupsRpt.txt" -append                 #Iterate throu

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/

Application error when access /_admin/owners.aspx, Error=User cannot be found. reolved using PowerShell

While trying to set site collection admin and secondary admin from central admin in SharePoint I got below error in ULS log, Application error when access /_admin/owners.aspx, Error=User cannot be found.   at Microsoft.SharePoint.SPUserCollection.GetByID(Int32 id)     at Microsoft.SharePoint.Administration.SPSiteAdministration.get_SecondaryContactLoginName() User below PowerShell Add-PSSnapin "Microsoft.SharePoint.PowerShell" Set-SPSite –Identity https://contoso.com/sites/it/ –SecondaryOwnerAlias domain\umorbale https://technet.microsoft.com/en-in/library/ff631156.aspx?f=255&MSPPError=-2147217396 https://pholpar.wordpress.com/2011/05/13/user-cannot-be-found-error-solved-using-a-sql-query/

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!