Tuesday, September 22, 2015

App Launcher Visibility: SharePoint 2016 IT Preview


Microsoft has introduced App Launcher providing a new navigation experience in SharePoint 2016. It provides a quick access to the apps.
After executing the post-setup configuration wizard (psconfig.exe) of SharePoint 2016 IT Preview, the App Launcher was not visible on Central Administration site. I created a new web application with single site collection. When I accessed the new site collection, App Launcher was not visible.

At this moment, I have not created any service applications. Clearly I am not having all the functionality of SharePoint 2016 IT Preview in place to expect it to surface all UI components. I concluded that App Launcher might have some dependency on one (or more) service application(s).
I came across three scenarios which affected the visibility of App Launcher even after creation the service applications. This post provides more insight to each of the scenario.

Scenario #1: App Launcher not visible when no service application is created.
There are multiple service applications available in SharePoint. Which service application(s) the App Launcher has dependency on? Looking at the service applications list, I thought my farm should have App Management service application. I created App Management service application.
[Note: Before creating App Management service application, I created some of the basic service applications (i.e. State Service, Usage and Data Collection Service, Secure Store Service, Subscription Settings Service) along with Search service.]
Even after creation of App Management service application, the App Launcher was not visible.
Being curious, which service application make the App Launcher visible, I started looking into the SuiteNav feature and the related assemblies for the control rendering. The investigation led to below method in disassembled assembly.

 
The App Launcher will not be visible unless and until we have configured the My Site Host Url in User Profile Service Application. [Note: If you create User Profile Service Application in partition mode, you’ll not be able to configure the My Site Host Url.]
I created User Profile Service Application but still the App Launcher was not visible. I checked service connections group. The User Profile Service Application proxy was not selected for the default service connection group.
I added User Profile Service application to the service connection group

And…it’s there! It started showing the App Launcher in Central Administration.
Conclusion:
  1. App Launcher has dependency on User Profile Service Application.
  2. App Launcher requires User Profile Service Proxy in the web application’s service connection group.
  3. App Launcher will not show up if partition mode parameter is used to create User Profile Service Application [Not Tested. Reasoning: User Profile Service does not provide my site related configuration if the service created with partition mode.] It does not mean that App Launcher will not be available for multi-tenant farms. I will keep it open to explore more this topic.
Scenario #2: App Launcher is visible on Central Administration site but not on the other web applications.
The site collection, which I created initially, is not showing the App Launcher but the central administration site is showing it. Both web applications have the same default service connection group. I tried creating new web application and new site collection, it also had the same problem. I spent many hours after my work schedule on this.
With prior experience with old SharePoint versions, a thought came to my mind “Does it has anything to do with availability of root site collection?”. In both web applications, I have created the site collection on “/sites” managed path. There was no site collection on the root (“/”) of the web application.
Quickly I created the root site collection and … it’s there!
Conclusion:
  • App launcher will not be shown if there is no site collection created at the root of the web application.
Scenario #3: App launcher not visible on central administration site after IIS Web Site binding changes.
I have updated the IIS web site binding to “xyz.pqr.com”. I browsed the central administration site from Internet. I could access the site but the App launcher is missing from the site. But the site collections from other web applications were showing it when accessed from the Internet.
This one was very quick as I have intentionally avoided to specify the AAM configuration for the central administration web application. I added the AAM public URL and it started showing the App Launcher on the Central Administration site when accessed from the Internet.
Conclusion:
  • AAM configuration should be in place when we are accessing site from non-server machine and using fully qualified domain URL.

Saturday, June 29, 2013

Alerts Timer Job Failure SharePoint 2010

After migrating to SharePoint 2010 from MOSS 2007, we faced issues of alerts not being sent. Many users reported the issue and it was an intermittent issue. It was failing for few lists. Even if there are two lists on a site, alerts from one list are working fine, but the other list was failing to send notifications.

I checked the ULS logs and it has entries for COM exception.

Timestamp    : 6/22/2013 8:30:01 AM
Continuation : False
Process      : OWSTIMER.EXE (0x1D64)
ThreadID     : 8464
Area         : SharePoint Foundation
Category     : Alerts
EventID      : c6f5
Level        : Verbose
Message      : AlertsJob, Filter for Immediate subscription with id {2D5D9F07-D0CE-478F-BFBD-B05AE9C8D337} matched event with Id 11471939
Correlation  : aa6f068e-da75-44ff-bcb1-9ef3313dccde
Context      : {}

Timestamp    : 6/22/2013 8:30:01 AM
Continuation : False
Process      : OWSTIMER.EXE (0x1D64)
ThreadID     : 8464
Area         : SharePoint Foundation
Category     : General
EventID      : 837l
Level        : Exception
Message      : An unhandled exception occured. Watson will be invoked.
Correlation  : aa6f068e-da75-44ff-bcb1-9ef3313dccde 

Exception stack trace:
at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)
at Microsoft.SharePoint.Library.SPRequest.DispatchTimerJob(Int32 lJobType, Guid gVServerId, Int32 lScope, Guid gDatabaseId, String bstrDSNServer, String bstrDSNDatabase, String bstrDSNUser, String bstrDSNPassword)
at Microsoft.SharePoint.Administration.SPNativeDatabaseJobDefinition.Execute(Guid targetInstanceId)
at Microsoft.SharePoint.Administration.SPTimerJobInvokeInternal.Invoke(SPJobDefinition jd, Guid targetInstanceId, Boolean isTimerService, Int32& result)

The common thing in these errors was "it was throwing exception after applying filter for immediate subscription as highlighted above.

I first located the alert by using PowerShell script given below. I used the script for web application on which the timer job was failing.

$webs=Get-SPWebApplication <webappurl>|Get-SPSite -Limit All| Get-SPWeb -Limit All
$alert=$webs|%{$_.Alerts}|?{$_.Id -eq "<subscriptionid>"}
$alert|Select @{Name="User";Expression={$_.User.LoginName}}, List, @{Name="Url";Expression={$_.List.ParentWeb.Url}}

The script listed the "SharePoint\System" account as user. This was weird and so we verified on the site "is it really a system account subscribing the alerts?". Yes., it was "System Account."

System account cannot subscribe to alerts in SP2010. We were not sure whether it was possible in MOSS 2007. System account do not have Email ID and so we cannot subscribe to alerts using System Account. This was causing the failure of the Immediate Jobs timer job.



The timer job was failing for the lists where system account had subscription and for other lists it was working.

We removed all system account subscription on all sites in the web application and there were no failures any more.

Hope this will help others.

Sunday, May 26, 2013

Display Form returning 404 Not Found in a List created from Custom List Template

Recently one of the SharePoint site user complained that display form of a list is not working. We checked the list and everything was properly set (DefaultDisplayFormUrl ), but still it was not working. The list was created from a custom list template. The list template was based on an existing list (original list). The original list is working fine but the new created from the template was returning "404 Not Found" error.

I opened turned OFF the dialog and checked the URL it uses to launch display form. As the normal list behaves, it is first invoking the "listform.aspx" page with  query string. The "listform.aspx" page normally causes redirection to appropriate page type specified in the query string. Due to the 404, browser was not displaying the correct final URL. So I just launched the developer tools and checked the HTTP request/response cycle.

The "listform.aspx" is sending 302 for redirection but the location it was referring to the original list. As the original list does not have the new created display form of the new list. It was returning 404.

Then we removed content type ID from the query string and it was working fine. We further investigated and checked if it refers to wrong content type. It was referring to the content type available with the new list. So content type is not the issue.

Why "listform.aspx" referring to the original list?

I de-compiled the code of the "listform.aspx". The "listform.aspx" page invokes a method of ListFormWebPart. This method prepares the final display URL  based on the "DisplayFormUrl" property of content type.


The PowerShell script confirmed it that the problem is with the content type display form URL. The content type is right but it's property has wrong reference.

$web=Get-SPWeb http://
$list=$web.Lists[]
$ct=$list.ContentTypes[0];
$ct.DisplayFormUrl

We updated the DisplayFormUrl in script and it started working. Great job!!!

Monday, March 25, 2013

Lists.asmx: Method not Found


Recently we had an intermittent issues with lists.asmx. It was giving us SoapServerException as below:
Method not found: 'Microsoft.SharePoint.Utilities.SPChunkedStringBuffer Microsoft.SharePoint.SPListItemCollection.GetXmlInternal(Boolean, System.Collections.Hashtable, Boolean, Boolean)'.

The issue was occurring infrequently. We located the issue on two WFE machines.

The exception was saying "Method not found." This is little weird as how OOB dll file miss this method and what is the DLL it is referring to.

I opened the lists.asmx and found that it refers to STSSOAP.DLL.


I searched for the DLL file and we located at two different locations : 1. SharePointRootFolder\ISAPI 2. WebApplicationVirtualDirectory\_app_bin

While browsing through these directories I noted that the DLL files have different "Modified Date". We checked the other WFEs and this difference was not present there. The both files had different versions as "14.0.6024.1000" and "14.0.6122.5000". We recently had server patching and somehow this web application _app_bin folder had the old file and using it.

We replaced the DLL with latest version and the issue is resolved. :)


Monday, October 29, 2012

SharePoint 2013 REST Service

SP 2010 is the first version of SharePoint which supports REST API/Service (REpresentational State Transfer). SP 2010 has REST located at http://[web site URL/_vti_bin/ListData.svc.

SharePoint 2013 has few changes related to REST access URL. SP 2013 has REST located at http://[web site URL]/_api/.

SharePoint 2013 REST endpoints map to SharePoint Client object model types and members. As we know that, SharePoint Client Object Model allows access to various objects in the hierarchy down from the Site Collection i.e. Site (Site Collection), Web (Web Site), List, ListItem etc.

Similarly, the SP 2013 REST allows access to object Site and the objects below it in the hierarchy.

SP 2010 REST API was allowing access to only lists and their items in a web site. SP 2010 REST never given access to Site or Web objects whereas SP 2013 REST can access these objects as well.

Let us see how REST works and how the REST endpoints are formed.


Access Site Collection Object and its properties

http://[Web Url]/_api/site

Use above URL format to access the site collection object in Atom feed format. Do you re-collect “Site” object in Client Object Model representing site collection? Here we used the same object after “_api/”.

Web URL can be any web site in the site collection. Site object can be accessed from any web site in the site collection.

Look at the below XML response for the site collection object.


 
There are two XML namespaces “m:” and “d:” representing metadata and data namespaces respectively.  Complex types and collections are represented as Atom feeds in REST and belong to default namespace. The properties with primitive types belong to “<m:properties>” node.

The “term” attribute on the “<category>” node has value set to fully qualified name of the type of Client Object Model.

The <link> node represents the collections and complex type properties of the object. The “href” attribute provides the /site relative URL to access the atom feed for collection/complex type.

e.g. To access Root Web of the site collection, use

http://[web URL]/_api/site/RootWeb

Similarly one can access the primitive properties by appending the name property in URL after “/site/”. The response is not in Atom feed format. It is just a XML fragment. e.g. To know if the site collection allows use of SharePoint Designer, use

http://[web URL]/_api/site/AllowDesigner

The properties presented in REST response do not contain all properties of “Site” type. e.g “Site” has property “Usage”. There is no <link> node for it in the response, but we can access the property using below URL.
http://[web URL] /_api/site/usage

Access Web site and its properties
http://[Web Url]/_api/web

The above REST endpoint lets us access the basic Web object of Client Object Model.
 
To read web “Title”, use

http://[web URL]/_api/web/title
To read lists collection in a web site, use

http://[web URL]/_api_web/lists

The response from above REST endpoint contains nodes for each list/library in the web site. You can access the specific list, using the <id> node value inside the specific list’s entry.

To read the specific list details, use
http://[Web Url]/_api/web/Lists(guid'[Guid of the list]')

To access the items of a list, use
http://[Web Url]/_api/web/Lists(guid'[guid of the list]')/Items

To access an item with specific ID, use
http://[Web Url]/_api/web/Lists(guid'[guid of the list]')/Items([id of the item])

Thursday, October 4, 2012

Related List /Items View in SharePoint 2010

SharePoint 2010 has an enhancment to show related list views. There is pre-requisite to make it work. You should have lists with relation established using lookup columns.

Let's try it.

1. Create a custom list named "Country". We will use "Title" column. If you want to add any new columns, you can do so.

2. Create one more list named "City". Create the columns as shown below. The "Country" must be a lookup column to "Country" list.

3. Add some city information to the list.

4. Right-click on any city and click "Open in New tab/Window". This way it will launch the display form in browser window. This will make "Site Actions" menu available. The "Site Actions" menu is not available in dialog. Click "Site Actions" -> Edit Page.

Click inside the existing web part zone. The ribbon starts presenting "Page Tools" tab. It has a button "Related List". Click it. It shows the all related list. In our case, it is city.

5. Click on the related List "City". It added a related items view as shown below. It will only show cities for the selected country. i.e. the country for which display form is shown.

6. Do not forget to click "Stop Editing" in the "Page" tab of ribbon. This actually saves the page with changes.

7. User can add items to the related list using related items web part. Click the "Add new item" link and it starts showing add new item form page for the "City" list. You can add item here. If the Country display form (View Properties) is being preseneted for "India", still you can add item for "Japan" from this screen. Be careful.


8. You can change the view of related list items. You can add/ remove column from the view using "Edit the current view" link or selected the appropriate view from the drop-down.

9. Edit the current view, after saving view changes takes back to the display form which will show nothing. So close the browser tab/window and reopen. You can see the changes.

Using SPD 2010:

1. Create a new view "DetailedView" for Country list. The view must be same as All Items view.
2. Check-out the page in SharePoint Designer 2010. To accomplish this, open the list using All Files option in SPD 2010.
3. Right-click the page and click on "Edit in Advanced mode".
4. In "Design" view, click inside the available web part zone. Put the cursor at a location where you want to add the related list items web part.
5. Click "Insert" tab in ribbon and it has a button called "Related Item View". This button presents all related lists as shown below.

6. Click the "City:Country" and it adds the related items view on the page as below. Save the page and check -in
7. The view page on browser refresh starts showing a new column as shown below to select an item and the related items are shown for the selected item. Selected item has dark black arrow icon.
 


I will suggest to use browser based method as it will avoid the un-ghosting of the page. But if you would like to customize the XSL of related items web part, better to use SharePoint Designer.

Saturday, September 29, 2012

My First Look at SharePoint 2013 Site

[The content is specific to SharePoint 2013 Preview. The RTM may come up with some changes.]

SharePoint 2013 - I was waiting for you. Yes, today I started working on SharePoint 2013 (Preview) site.

I put the URL in browser and this is what I see on home page.


I have highlighted few parts in the picture. These are new in the UI and are not self-explanatory.

Let us have a look at each one.

Edit Links

What links are they talking about? Do they mean page links? Can we re-organize or update page links? Why duplicates are placed at top and below left navigation? Too many questions... came to my mind. Let's give it a try.

Click "Edit Links" in the top. The UI changes in-place as below.

I clicked the "+" sign and it presented me with screen below. It asks for the "Text to be displayed as link" and the target URL.

Can't I specify the target to open the link in new window? There is no way. This a Global navigation, use it only for links scoped to the content in the site collection.

Click "OK". It added a link in Global navigation. But the link is not saved... we have to click on "Save".

Here is how it looks after saving.

Can I edit the link? Yes, I can. Click on "Edit Links" and then click on the link itself. It presents the below screen changes. Click on "Link" icon which is similar to infinity symbol.

It allows to update the link. (Note: This applies to only saved links. If you have added a link but not saved and before saving you want to edit. It does not allow to do it.)

So the duplicate below left navigation...it updates the links in left navigation and it should contain links scoped to the site level content.

Focus On Content

There is an icon on right side at the top icons collection. On hovering the icon, it displays a tooltip saying "Focus on content".

I clicked it...the left navigation bar disappeared. I again clicked it, the left navigation re-appeared. This is really good. Rather than the navigation items occupying the real-esate of screen, it will become available for content. User will have a better experience while working with the content. When required, user can invoke the navigation on demand. Really, cool...!

Stay tuned...!more stuff coming up about SP 2013.

(The screen-shots are from Office 365 Preview site. There is not much difference in the UI of actual SharePoint 2013 site. So the notes apply to SharePoint 2013 Preview site.)

Sunday, September 23, 2012

List the "vti_" properties using PowerShell

Every file/document in SharePoint possess some meta-info. It is stored in hashtable presented by SPFile.Properties property. Most of the properties start with "vti_". We cannot write the "vti_" properties as they are read-only.

But we can use this property-bag store custom meta-property for the file. We can manage the custom properties using below method:
  • SPFile.AddProperty
  • SPFile.SetProperty
  • SPFile.GetProperty

SPFile.CustomizedPageStatus property determines the customization status of wiki page or page layout using below properties.
  • vti_setuppath
  • vti_hasdefaultcontent
Different SharePoint objects has the hashtable based property to store these kind of properties. e.g SPWeb.AllProperties. SPWeb.AllProperties["__PagesListId"] stores the GUID value of "Pages" library created on activating publishing feature.

Changing the UIVersion of migrated sites automatically updates the master page to appropriate UIVersion. This is possible because of the SPWeb.AllProperties. It stores the master page details related to each UIVersion.

PowerShell script to list the "vti_" properties of a file.

$web=Get-SPWeb <webSite URL >
$list=$web.Lists["Site Pages"]
foreach($item in $list.Items)
{
    $item.File.Name
    Write-Host "**********"
    foreach($key in $item.File.Properties.Keys)
    {
        Write-Host $key "=" $item.File.Properties[$key]
    }
    Write-Host "------------------*****---------------------------"
}

PowerShell script to list "vti_" properties of web site.

$web=Get-SPWeb <webSite URL >
foreach($key in $web.AllProperties.Keys)
{
     Write-Host $key "=" $web.AllProperties[$key]
}

Have a look!

Saturday, July 7, 2012

Missing IIS_WPG group on SharePoint 2010 server

If you have came across this TechNet link, you will find that the SP 2010 setup user account should be present in IIS_WPG group. We faced some issue for which we were investigating the account permissions and their group memberships.

On our servers we found that there is no IIS_WPG group. Initially I thought this can be the cause of issue. But I also noted that there is IIS_IUSRS group. I never paid attention to this group or never came across any such group in the context of Web development.

I googled for IIS_WPG and IIS_IUSRS keywords. I found a good link explaining the difference of these group. IIS_WPG is replaced by IIS_IUSRS group in IIS 7. Our servers are Window 2008 based and so our systems have the IIS 7.

IIS_WPG group is specific to earlier versions of IIS.

So if you find similar discrepancy in SharePoint systems, do not panic. Check for availability of IIS_IUSRS group.

Friday, June 15, 2012

Insert Picture From SharePoint is disabled in CEWP

Recently I came across a scenario in which the user was using content editor web part (CEWP) and using the Rich Text Editor ribbon of SharePoint 2010 to format the content. The user noted that "Insert Picture From SharePoint" option is disabled on a page.



I started investigating and came across MSDN Forum where it is mentioned that activating a publishing feature will resolve the issue. The site must be in publishing context. In our case, the site has the publishing feature activated.

We tried creating various kind of pages (Wiki Page, Web Part Page and Publishing Page). The option was enabled for every kind of page on the same site.

The option was disabled for only one page i.e. default.aspx. The page resides at the site root. I created a web part page in "Site Pages" and verified the option is enabled for the page. I opened the site in SharePoint Designer 2010. I moved the page to the site root. Again, I browsed for the page in edit mode and verified the option, it was disabled.

The page at site root does not belong to any library and has no associated content type for it. The page has few content management features disabled such as "Versioning", "Edit Properties". This is because the page was not child of any library (an orphan page or the parent is site).

Publishing feature has a strong bond with content management features. As the page do not have content management features available, it was not able to take advantage of the publishing context also. That's the reason, it was showing "Insert Picture From SharePoint" in disabled state.

This is not only this option, it also disables capabilities to cut, copy, paste in the Rich Text Editor.

Wednesday, June 13, 2012

Content Editor Web Part duplicating content

Today I received a request mentioning that Content Editor Web Part is duplicating the content. The user was adding clock object prepared in Adobe Flash. This clock was being duplicated whenever the user is editing the web part.

I checked the content editor web part. It has got too many "<embed>" tag. The tags were being duplicated. The clock was being rendered using some JavaScript method. We inspected the method. The method was using "document.write" to add the "<embed>" tag.

Content editor web part renders its HTML/JavaScript content on its canvas. So document.write was adding "<embed>" tag on every "Save" for the web part. So every edit action for the web part was adding "<embed>" tag causing duplicate clocks (content).

We resolved the issue by creating separate content file for Content Editor Web Part. The content file is linked to the Content Editor Web part. As the "document.write" is moved to separate file, for every request the file is read and parsed for render. "document.write" do not append content in the file. So it has no duplication of content.

Always use separate content file whenever we have a content which includes "document.write" in JavaScript.

More Reference(s):

Wednesday, May 23, 2012

SPDocumentLibrary.CheckedOutFiles? A Common Misunderstanding

What is a checked out file?
Any file which locked for changes...so the changes are not visible to the other users. In SharePoint, we have a option to check out a file.
Go to the library, open a file's ECB (Edit Control Block) menu options and clik "Check Out" menu item.

So any file, which is checked out this way, is a checked out file. Isn't it? Yes, it is checked out file.

Now, try this.
Write a small console application, which will display count of SPDocumentLibrary.CheckedOutFiles. In case of SharePoint 2010, a small PowerShell script will do.

Execute the utility and note down the count of Checked Out files. Go to a document library and check out one file. Re-execute the utility and read the count...It does not change.Try again with two-three files. It does not change the count of SPDocuemntLibrary.CheckedOutFiles.

Why?
 MSDN describes "SPDocumentLibrary.CheckedOutFiles" as "the collection of files that are uploaded to the document library but are not checked in."

If the document library requires check out before editing any file and you upload a file to this library...the file will added in a checked out state. The file does not have a checked in version available. The file will not be visible to any one before check in.

SPDocumentLibrary.CheckedOutFiles represent the collection of files, which do not have a checked in version.

"Requires Check out" setting is available in "Version Settings" of library.

Can we override Check out of these files from Object Model?
SPDocumentLibrary.CheckedOutFiles is a collection of SPCheckedOutFile objects. SPCheckedOutFile does not derive from any class. SPCheckedOutFile does not have any member to check in the file.

SPCheckedOutFile has a property "ListItemId". If we exploit it to retrieve SPFile object, then we can check in the file. SPFile has a method "CheckIn". Code must be executed with the credentials of the user who has the ownership of these files. As the files are not visible to others, code with other user credentials fails to retrieve the SPFile object for these files.

SPCheckedOutFile type has a method "TakeOverCheckOut". If we use this method, you will have the file ownership and then we can retrieve the SPFile object for check in purpose.

Can we override check out of these files from UI?
These files are only visible to the user who has uploaded the files. Then how to override the check out for these files.
Go to the library settings, you will see a link "Manage Checked Out Files" in "Permissions and Management" category. MOSS 2007 and SharePoint 2010 has different versions of the link text as  follows.
MOSS 2007:
SPS 2010:
SharePoint 2010 corrected the confusing text.

So click on this link, and you can see the files which do not have checked in version. The UI provide the option to take the ownership of these files. Take the ownership of this files and from library view, you can check in/ delete the files. Taking ownership of these files, makes the files visible to you only and other users can not see the files.

Files checked out which have checked in version
Any file which is explictly checked out from the library...is visible to all with check out status. It can be retrieved as SPFile object. SPFile has properties to read the details of check out. These details are also presented in UI.

SPFile.CheckOutStatus property indicates whether the file is checked out or not. There are other members of SPFile which gives details about check out. e.g.CheckedOutBy, CheckedOutDate etc.

As the files are visible to all, we can easily override the check out of these files from UI or Object Model code.

To summarize
SPDocumentLibrary.CheckedOutFiles represents files which does not have checked version. This property does not count the files, which are explictly checked out. This property should not be used to report the number of checked out files.

Use loop in object model and count the files with CheckedOutStatus turned ON.  Then add the count of SPDocumentLibrary.CheckedOutFiles.

In UI, create a view of checked files, note the count of files. Visit "Manage Checked out files" link in library settings, count the files. Add the counts of these files.

Tuesday, May 8, 2012

Home page of Wiki Page Library / Site

SPFolder class has a "WelcomePage" property. This property is used to set home page for a site / a library or a folder. How to do use it in PowerShell?

1. To set site home page.

$web=Get-SPWeb {webUrl} #remove curly braces
$web.RootFolder.WelcomePage="default.aspx" #change to appropriate value
$web.RootFolder.Update()

2.To set a default page for Wiki Page Library. If clicking on "Wiki Page Libray" in quick launch menu or in all site contents directly opens a page in the library instead of showing the library pages, execute below script. It will start showing all pages.

$web=Get-SPWeb {webUrl} #remove curly braces
$list=$web.Lists[{Wiki Library Name}] #curly braces must be removed.
$list.RootFolder.WelcomePage="Forms/AllPages.aspx"
$list.RootFolder.Update()

Saturday, May 5, 2012

List Settings Error 0x80070024

Recently we faced a problem accessing "List Settings". The error said "The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator. 0x80070024." The List Settings page was working fine in the other site collections.

We created one custom list with one item. The list has the same issue even though it has single item.

We found an entry in ULS Logs saying "big list, slow query operation" The log has mentioned the List GUID which is being queried. I wrote a Powershell to find the list. The list is hidden "Workflows" document library. I tried the document library URL in browser, it returned me "404 Not found". One of my colleague used the list guid with _layouts/listedit.aspx(application page List Settings refer) and it did show us the Library settings. We verified the library settings but it did not helped.

I wrote a PowerShell to find the number of items in the list and it returned 0. So there are no items but still it is causing the issue. We were clueless about the behavior. I wrote the below PowerShell script, executed it, and there were no errors on hitting the "List Settings".

$web=Get-SPWeb [webUrl]  #remove the square bracckets here
$list=$web.Lists["Workflows"]  #Keep the square brackets in this line.
$list.EnableThrottling=$false
$list.Update()

For the time being, we used this solution. I am investigating the cause for the issue. The "Workflows" document library is used to store the site level workflows. The library is created by SharePoint Designer (SPD) on first ever SPD workflow creation in the site.

Visit again, for the updates!
[Update 05/08/2012: I found that the "Workflows" library reports -1 in ItemCount. As such, no list or library should report ItemCount as a negative number. As mentioned in this post, Microsoft has accepted that MOSS 2007 has the issue of negative ItemCount. The site, we are referring to, is a migrated site. So the library was reporting negative ItemCount. Negative item count is a cause for failure of indexing operation. If indexing fails, queries perform slow. It was causing the throttle issue even though the "Workflows" library is empty.

Resolution: If the "Workflows" library is empty, delete it. SharePoint Designer will recreate the library on SPD workflow creation. If the library is not empty, then there will be no issue as ItemCount will always report positive number.

The issue may occur only in migrated sites hoping that Microsoft has taken care of the issue in SharePoint 2010.]

Sunday, April 29, 2012

Missing "Manage Permissions" in Document Library

While working on a site, I encountered a document library where it was showing fewer menus in Edit Control Block (EBC) (also referred as List Item Menu). I noticed there is absence of "Manage Permissions" menu. It was a clear indication that document library has been broken. I tried to figure it out looking at the list schema, field schemas, views etc. but of no use.

"Manage Permissions" is the essential menu item to manage the item level permissions. Client was also interested in it.

The document library was the only one which was misbehaving in the site.

After looking at various options, I realized that we can provide "Manage Permissions" link using Custom Action.

SharePoint Designer 2010 has made it very easy to create Custom Action. Custom Actions can be created to display the new/edit or display form, to initiate a workflow or to navigate to a url. Custom Actions also support URL tokens such as {ListId}. I just observed the "Manage Permissions" link in other document libraries and analyzed the URL with query string parameters.

"Manage Permissions" navigate to : _layouts/user.aspx (application page)
Query string comprises of obj (it has list id/GUID, item id and entity category), and list (it has list GUID).

URL looks like as below:
http://server/<weburl>/_layouts/user.aspx?obj=<list Id>,<item id>, LISTITEM&List=<list id>

Custom Actions support various URL tokens. I referred the below URL tokens.
  1. {ListId} --List Guid
  2. {ItemId} -- Item Guid
My URL for custom action :

http://server/<weburl>/_layouts/user.aspx?obj={ListId},{ItemId},LISTITEM&List={ListId}

That's it! I named my custom action as "Manage Permissions". This is just a workaround. We will investiagate the reason behind misbehave and update the post.

Thursday, April 26, 2012

Filterable Multi-valued PeopelPicker Column using PowerShell

Recently I came across an error while filtering the multi-valued PeoplePicker column. The error reads "Cannot show the value of filter. The field may not be filterable, or the number of items returned exceeds the list view threshold enforced by the administrator." There are only four values in the column, surely it has no rleation to the list view threshold value.

Internally, SharePoint server uses "_layouts/filter.aspx" application page for filter values which are presented in an iFrame. I checked the ULS logs and copied the Request URL with filter.aspx. I pasted it in browser and hit "Enter". It returned no result.

What is multi-valued field?
The field which allows more than one values or which allows multiple selections. The multi-valued fileds are non-sortable, non-filterable. Multi-valued fields cannot be indexed.

Fix:
This behavior can be overridden. Every field has an associated schema. Multi-valued fields are marked as "Sortable =false" in the schema for performance reasons. Note: Apply the workaround wherever it is unavoidable.

If we mark the multi-valued PeoplePicker as "Sortable=true", the column turns filterable/ sortable. This can be achieved using SharePoint Server Object Model or using Windows PowerShell (I love it).

PowerShell Script to mark the column as Sortable:

$web=Get-SPWeb <weburl>
$list=$web.Lists[<list title>]
$field=$list.Fields[<field title>]
$strSchema=$field.SchemaXml
$str=Schema$strSchema.Replace("Sortable=`"FALSE`"","Sortable=`"true`"")
$field.SchemaXml = $strSchema
[Update: I noticed that multi-valued "person or group" coulmn in other web application was showing filter choices even though "Sortable=false". Googling did not help. I checked at various levels and found that "Online Presence" setting causes this error. If Online presence setting is turned OFF, SP 2010 starts showing this error for multi-valued columns when tried to filter. So turn it ON, and...no error, filter choices are shown back. The Online Presence setting is available in Web applications's General Settings.]

Sunday, April 8, 2012

Powershell to find site collections with specific feature activated

This is a one liner Powershell to find site collections which have the specific feature activated. See the below example, it display URLs of site collections where "SharePoint Publishing Infrastructure" feature is activated. The "PublishingSite" is the name of publishing infrastructure feature.

Get-SPSite -Limit All| Where-Object {(Get-SPFeature "PublishingSite" -ErrorAction SilentlyContinue -Site $_.Url) -ne $null } | Select Url

So the format is

Get-SPSite -Limit All | Where-Object { (Get-SPFeature <Feature Name> -ErrorAction SilentlyContinue -Site $_.Url) -ne $null } | Select Url

Note that it will only check for site collection scoped features. The above Powershell can be modified for web scoped features as below.

Get-SPSite -Limit All| Get-SPWeb -Limit All | Where-Object { (Get-SPFeature <Feature Name> -ErrorAction SilentlyContinue -Web $_.Url) -ne $null } | Select Url

e.g. To check Publishing feature activation status at web scope, it will look like as below. "PublishingWeb" is a web scoped feature.

Get-SPSite -Limit All| Get-SPWeb -Limit All | Where-Object { (Get-SPFeature "PublishingWeb" -ErrorAction SilentlyContinue -Web $_.Url) -ne $null } | Select Url

This powershell block can be extended for web application/Farm scoped features also.

Friday, December 2, 2011

Information Architecture and Faceted Navigation in SharePoint 2010

SharePoint 2010 has new features included (such as Taxonomy, Document Sets) and search improvements (such as Refiners). This has brought in a whole lot of changes to the thought process related to information architecture.

In MOSS 2007, we dealt with a linear guided navigation. SPS2010 improvements and new features introduced faceted navigation. It is also referred as faceted search or (free form) guided navigation. The faceted search presents users with a list of relevant suggestions for refining the search results by document type, site, author, modified date, tags etc.

Information architecture is the key in designing the content management systems, knowledge management portals, e-Commerce sites and so on. Consider below points while deciding on Information architecture.

• Content Roll up: Using Content Query web part, relevant and related content can be made available on content pages, document set welcome pages etc. Content Query web part has few improvements related to managed metadata (taxonomy) columns. Read here what’s new in content query web part.
• Refiners: This is a key to faceted search. The refinement web part can be used to narrow the search results.
• Extensibility of Search Web part: SPS 2010 has search web parts which can be extended. In MOSS 2007, these web parts are sealed. Scenario based search functionality can be extended and used on various pages, document set pages.

I have listed here few of the points. There are many features in SPS 2010 which we can exploit for the better information architecture and good navigation providing better user experience.
Few links about faceted search and information architecture.
Building Information Architecture in SPS 2010
Faceted Navigation
How Microsoft is leveraging the features in Infopedia and Microsoft Academy Mobile
Case Study: Microsoft Infopedia

Tuesday, August 2, 2011

SharePoint: Site Columns and Content Types

There are various posts on the internet describing the site columns and content types. In this post I am co-relating these with concepts of objects and classes. This will help the developer visualize these concepts differently.

Content and Object

Object has data. Class provides the set of attributes to detail the object instances.

Content is data. Content has two categories: Structured and Unstructured.

Content comprises of documents and list items. Content does not include list or library itself. List or library helps user to organize the content.

Structured content is the one which separates its storage from its display. e.g. List Items can be sorted/filtered and viewed in List web part or data row in a SQL data table.

Unstructured content is the one which cannot be viewed separately the format in which they are stored. e.g. Word document cannot be viewed without the MS Office Word.

Content type provides the set of attributes to define the metadata about content. The attributes are provided in the form of columns/fields in the list or at the site level.

Site Column

When the column is defined at site level, it is a site column. The site column is reusable across all lists and libraries in the site.

This is very similar to have property declared in an interface and will be available across all objects implementing the interface.

Content Type

Content type is a set of site columns. The site column helps in describing the content. The content type can be used across the lists and libraries in the site.

This is just like a complex data type. The data types/ classes has properties to describe the object.

Wednesday, April 13, 2011

Document Library Creation with Specific Document Template Using Server Object Model

Introduction: There is no way in SharePoint UI to create a document library with blank Excel/PowerPoint document template. But it is possible to create a document library with such document templates programmatically.

Technicalities:
I will first take you through the classes involved in development.


  • SPListCollection

  • SPListTemplateType

  • SPListTemplate

  • SPDocTemplate


SPListCollection has Add method with 7 overloads. Look for the method signatures here.



We will concentrate on the following signature:



public virtual Guid Add(
string title, //Title for the library
string description,//Description about the library
SPListTemplate template,//The list template. We are interested in Document Library.
SPDocTemplate documentTemplate //The document template for library.e.g. Excel, Word or Powerpoint etc.
)

SPListTemplateType is a enumeration. The enumeration has underlying integer values which match the Type attribute of ListTemplate element. Please visit here for details.


SPListTemplate represents the list definition or list template for the list. The list definition/template has the views and fields defined. SPWeb.ListTemplates returns the list definitions for the web site. SPSite.GetCustomListTemplates method returns the list template collection for the site collection. More details.



SPDocTemplate represents the document template. Whenever we create a document library, it is created by using blank Word Document template. There are many document templates available in SharePoint 2010 OOB. The document templates have IDs. The ID is used to filter the document template collection presented by SPWeb.DocTemplates property. Document Template IDs list follows:












Document Template IDDescription
101A blank Microsoft Word 97-2003 document.
103A blank Microsoft Excel 97-2003 document.
104A blank Microsoft PowerPoint 97-2003 document.
105A blank Microsoft basic page ASPX document.
106A blank Microsoft Web Part Page ASPX document.
111A basic Microsoft OneNote 2010 Notebook.
121A blank Microsoft Word document.
122A blank Microsoft Excel document.
123A blank Microsoft PowerPoint document.


Code:

using (SPSite site = new SPSite(serverUrl)) {
using (SPWeb web = site.OpenWeb()) {
SPListTemplate lstTemplate = web.ListTemplates["Document Library"];
SPDocTemplate docTemplate =(from SPDocTemplate dt in web.DocTemplates
where dt.Type == 122
select dt).FirstOrDefault();
Guid newLibID =
web.Lists.Add("Expense Claims", "Excel Expenses", lstTemplate, docTemplate);
SPDocumentLibrary newLib = web.Lists[newLibID] as SPDocumentLibrary;
newLib.OnQuickLaunch = true;
newLib.Update();
}
}



The code is for console application.(I know you are aware, just for clarity).