Tuesday, July 14, 2015

SharePoint Calendar : Hide Columns in Month/Week View

One of my clients had a requirement where they want to hide Saturday & Sunday from Monthly and weekly view.

The problem is resolved in two steps:

1. Setting Monday as the first day of the week by regional settings. 

2. Specifying the CSS below:

/* Hiding Saturday & Sunday from Monthly Calendar View */
.ms-acal-month tr th:nth-child(1){
    display:none;
}
.ms-acal-month tr th:nth-child(7){
    display: none;
}
.ms-acal-month tr th:nth-child(8){
    display: none;
}

.ms-acal-summary-dayrow th:nth-child(8), .ms-acal-summary-dayrow td:nth-child(8){
    display: none;
}
.ms-acal-summary-dayrow th:nth-child(7), .ms-acal-summary-dayrow td:nth-child(7){
    display: none;
}

.ms-acal-summary-itemrow th:nth-child(7), .ms-acal-summary-itemrow td:nth-child(7){
    display: none;
}
.ms-acal-summary-itemrow th:nth-child(6), .ms-acal-summary-itemrow td:nth-child(6){
    display: none;
}
/* Hide columns in week view */
.ms-acal-detail tr td:nth-child(8){
    background-color:white;
    color:white;
    border-color:white;
}

.ms-acal-detail tr td:nth-child(7){
    background-color:white;
    color:white;
    border-color:white;
}

.ms-acal-week-top td div{
    border-color:white;
}

SharePoint Calendar: Change displayed time range on day/week view of calendar

One of my clients asked me to restrict the time range for  day/week view. They wanted to show only the working hours in views i.e. 9AM to 5PM.

Solution:
I changed the regional settings to specify working hours as 10 AM to 5PM and then I applied the below script.

/* Hiding timings 5pm onwards */
.ms-acal-detail tr:nth-child(37){
    display: none !important;
}
.ms-acal-detail tr:nth-child(38){
    display: none !important;
}
.ms-acal-detail tr:nth-child(39){
    display: none !important;
}
.ms-acal-detail tr:nth-child(40){
    display: none !important;
}
.ms-acal-detail tr:nth-child(41){
    display: none !important;
}
.ms-acal-detail tr:nth-child(42){
    display: none !important;
}

/* changing color of off timing */
.ms-acal-outday{
    background-color:white !important;
}

Wednesday, June 24, 2015

Creating Customized Document Information Panel for SharePoint Content Types with SharePoint 2013 Workflows

Make sure that "Update 2880963 for SharePoint Server 2013: May 13, 2014" is installed. You may find it at https://support.microsoft.com/en-us/kb/2880963

State Service must be configured for the web application before you can run SharePoint 2013 workflows.



1. Create Site Columns
2. Create Site Content Type
3. Attach document template to the content type
4. Create Document Library
5. Attach content type with document library
6. Create a new document in document library and check if document template and DIP is visible.
7. Open SharePoint designer and create list workflow for sales contract library
8. Create a new document in document library and verify that "Sales Contract Workflow" field is visible.
9. Open Info Path designer 2013 and create a new DIP by providing library url
10. Customize DIP and save the file in DIP library
11. Associate the new DIP with content type.

Wednesday, January 21, 2015

SharePoint Powershell script to change content type of all documents in a document library

Problem:
The reason why I had to write this scrip is due to the requirement from one of my clients. They want to change the order of Office (Word/Excel) document properties while creating a document from document template.

Note: If document properties are not visible, you have to select Advance Properties to show the properties dialog box.



I have tried several options to change ordering of content type, as well as for the document library field but to no avail.

Finally, I decided to create a new content that has all the fields of the old content type but with different ordering when I changed the content type of document to new content type. It worked like a charm and solved the core issue.

The next task was to update all documents in a document library to have a new content type.

Other scenarios, where you can use this script when you have content type of documents in document library.

Script is provided below for reference.

# This script can be used to changed the content of all documents in a document library
Add-PSSnapin Microsoft.SharePoint.Powershell
$url = "http://sharept13dev1:1123/"
$site = Get-SPSite -Identity $url
$web = $site.OpenWeb()
$documentLibrary = $web.GetList("Draft")
$OldCTName = "Old Content Type"
$NewCTName = "New Content Type"
$oldCT = $documentLibrary.ContentTypes[$OldCTName]
$newCT = $documentLibrary.ContentTypes[$NewCTName]
$newCTID = $newCT.ID

$documentLibrary.Items | ForEach-Object {
    if ($_.File.CheckOutType -eq "None"){
        $item = $_
        $Editor = $item["Editor"]
        $Modified = $item["Modified"]
        $_.File.CheckOut()
        write-host "Resetting content type for file" $web "/" $_.Url "from" $oldCT.Name "to" $newCT.Name
        $_["ContentTypeId"] = $newCTID
        $item["Editor"] = $Editor
        $item["Modified"] = $Modified
        $_.Update()
        $_.File.CheckIn("Content type changed to " + $newCT.Name, 1)

    }
}
$site.Dispose()