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()

Monday, November 10, 2014

Unable to save new document to SharePoint document library

One of the major features of Microsoft SharePoint Server is its document management capabilities. It allows users to create/edit/delete document in document library. Microsoft SharePoint provides a seamless integration with Microsoft Office products using plugins.

There are occasions when users of Microsoft Office products are not able to save documents in document library and they have to specifically send documents to specific libraries by specifying the url as shown below:



It would be a cumbersome task for the user to every time specify the url of these libraries. Eventually leaving the application unusable.

Why are you facing this issue ?


The reason why you are not able to save the documents directly SharePoint document libraries is due to enhanced security of Microsoft Internet Explorer and Microsoft Office.

You need configure these products in certain way before you can make SharePoint document library usable for your client.

Microsoft Office 2013:

Microsoft Internet Explorer: 



  Google Chrome:

Make sure that pops are enabled, otherwise you will get the following error:

Please try the following:

1. Check the General Settings for this document library for the name of the template, and install the application necessary for opening the template. If the application was set to install on first use, run the application and then try creating a new document again.

2.  If you have permission to modify this document library, go to General Settings for the library and configure a new template.


Wednesday, November 5, 2014

How to import/export term store in SharePoint 2013


Whenever you are planning to backup/restore site collection, always think about exporting and importing term store. 

You need to use the following scripts to perform these operations: 

Export:

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
#problem: The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.
#solution: you may need to open powershell as administrator
$mmsApp= Get-SPServiceApplication | ? {$_.TypeName -eq "Managed Metadata Service"}
#$mmsApp = Get-SPServiceApplication
echo $mmsApp.Id
#$mmsApp = #Copy the Id for managed meta data service and place.

$mmsproxy = Get-SPServiceApplicationProxy | ?{$_.TypeName -eq "Managed Metadata Service Connection"};
#$mmsproxy = Get-SPServiceApplicationProxy
echo $mmsproxy.Id
#$mmsproxy = #Copy the Id for managed meta data service app proxy and place.

Export-SPMetadataWebServicePartitionData -Identity $mmsApp.Id.ToString() -ServiceProxy $mmsproxy.Id.ToString() -Path "\\server\termstore.bak"


Import:

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
#problem: The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.
#solution: you may need to open powershell as administrator
$mmsApp= Get-SPServiceApplication | ? {$_.TypeName -eq "Managed Metadata Service"}
#$mmsApp = Get-SPServiceApplication
echo $mmsApp.Id
#$mmsApp = #Copy the Id for managed meta data service and place.

$mmsproxy = Get-SPServiceApplicationProxy | ?{$_.TypeName -eq "Managed Metadata Service Connection"};
#$mmsproxy = Get-SPServiceApplicationProxy
echo $mmsproxy.Id
#$mmsproxy = #Copy the Id for managed meta data service app proxy and place.

Import-SPMetadataWebServicePartitionData -Identity $mmsApp.Id.ToString() -ServiceProxy $mmsproxy.Id.ToString() -Path "\\server\termstore.bak" -OverwriteExisting




Unable to create a document in Sharepoint document library with specified content type in Office Word 2010


Problem
When I try to create a document using the specified content type in sharepoint document library, I get the following errors.

Environment
Windows Server 2012 R2 Version 6.3 (Build 9600) [on command prompt type : winver]
SharePoint 2013 with commutative updates May 2013 (15.0.4605.1002) [on sharepoint powershell type: get-spfarm | select BuildVersion]
Microsoft Office 2010 (14.0.4760.1000 (64-bit))

Error Messages
The operating system is not presently configured to run this application.

The document could not be created.
The required application may not be installed properly, or the template for this document library cannot be opened.

Please try the following:
1. Check the General Settings for this document library for the name of the template, and install the application necessary for opening the template. If the application was set to install on first use, run the application and then try creating a new document again.

2.  If you have permission to modify this document library, go to General Settings for the library and configure a new template.

Solutions
0. Install Desktop Experience feature 
Use powershell and run the scrip Install-WindowsFeature Desktop-Experience

1. Registry Fix
HKEY_CLASSES_ROOT\Installer\Components\55EAFA0B8A4403B428FDE038B252C621
Add a key where :
Name = "x86\1045"
Type = REG_MULTI_SZ
Data= #copy from the data from other string.

Note:
Once you apply this fix, you will be able to create a document in SharePoint document library but somehow if you try to create another document, it gives you the same error again.
So what you have to do ?
You have to close the browser and restart the browser again. Does not sounds good ?

Now you have to apply the below fix.

2. Hot fix

Package:
-----------------------------------------------------------
-----------------------------------------------------------
KB Article Number(s): 2726997
Language: All (Global)
Platform: x64
Location: (http://hotfixv4.microsoft.com/Microsoft%20Office%202013/sp1/owssupp2013kb2726997fullfilex64glb/15.0.4517.1001/free/464735_intl_x64_zip.exe)

-----------------------------------------------------------
KB Article Number(s): 2726997
Language: All (Global)
Platform: i386
Location: (http://hotfixv4.microsoft.com/Microsoft%20Office%202013/sp1/owssupp2013kb2726997fullfilex86glb/15.0.4517.1001/free/464734_intl_i386_zip.exe)


Note:
If you were not able to use the feature "Open with Explorer" in the ribbon, then now you will be able to use it.

Browser Support Matrix


Browser
Results
Internet Explorer
Working
Firefox
Not Tested
Chrome
Not Working

For Google Chrome:

Make sure that pops are enabled, otherwise you will get the following error:

Please try the following:

1. Check the General Settings for this document library for the name of the template, and install the application necessary for opening the template. If the application was set to install on first use, run the application and then try creating a new document again.

2.  If you have permission to modify this document library, go to General Settings for the library and configure a new template.