Friday, April 25, 2014

List All Checked Out Items in SharePoint

PowerShell scripts to list out all check-out file from the site and its sub site.  This will help the administrato to find you
the file details that are check-out in the system.

# enter your site URL $spWeb = Get-SPWeb http://kmtechsys/   function GetCheckedItems($spWeb) { Write-Host "Scanning Site: $($spWeb.Url)" foreach ($list in ($spWeb.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) { Write-Host "Scanning List: $($list.RootFolder.ServerRelativeUrl)" foreach ($item in $list.CheckedOutFiles) { if (!$item.Url.EndsWith(".aspx")) { continue } $writeTable = @{ "URL"=$spWeb.Site.MakeFullUrl("$($spWeb.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)"); "Checked Out By"=$item.CheckedOutBy; "Author"=$item.File.CheckedOutByUser.Name; "Checked Out Since"=$item.CheckedOutDate.ToString(); "File Size (KB)"=$item.File.Length/1000; "Email"=$item.File.CheckedOutByUser.Email; } New-Object PSObject -Property $writeTable } foreach ($item in $list.Items) { if ($item.File.CheckOutStatus -ne "None") { if (($list.CheckedOutFiles | where {$_.ListItemId -eq $item.ID}) -ne $null) { continue } $writeTable = @{ "URL"=$spWeb.Site.MakeFullUrl("$($spWeb.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)"); "Checked Out By"=$item.File.CheckedOutByUser.LoginName; "Author"=$item.File.CheckedOutByUser.Name; "Checked Out Since"=$item.File.CheckedOutDate.ToString(); "File Size (KB)"=$item.File.Length/1000; "Email"=$item.File.CheckedOutByUser.Email; } New-Object PSObject -Property $writeTable } } } foreach($subWeb in $spWeb.Webs) { GetCheckedItems($subWeb) } $spWeb.Dispose() }   #GetCheckedItems($spWeb) | Out-GridView   # alternative output file GetCheckedItems($spWeb) | Out-File c:\CheckedOutItems.txt -width 300

referred from  this link

Wednesday, April 23, 2014

Access SharePoint document or List item attachment from public site

Make the SharePoint document available to anonymous user without enabling anonymous access at web application level or site collection level.  If we enable anonymous access at top level then the content security will be lost.  But without enabling anonymous at top level we can make a document from document library or a list attachment to the public users using SharePoint list property.

SharePoint list has a property “AllowEveryoneViewItems”, which helps to make the document/list item attachment available to the public users.  This is the Boolean property. By setting this property to “TRUE” we can allow public user to access the document. But the public should access the direct document or list item attachment url because the public users will be able to navigate though SharePoint objects like document library or custom list.
Once the “AllowEveryoneViewItems” property set to “TRUE” then we can user the document url in any place over web for public access.

The property can be set in different ways using back end scripts or code but not through SharePoint UI.

1. Using Server Object Model
using (SPSite site = new SPSite("[site collection url]"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = rootWeb.Lists.TryGetList("[list title]");
if (list != null)
{
if (!list.AllowEveryoneViewItems)
{
list.AllowEveryoneViewItems = true;
list.Update();
}}}}

2. Using PowerShell Script

$web = Get-SPWeb -Identity "[site url]"
$list = $web.Lists.TryGetList("[list title]");
$list.AllowEveryoneViewItems = $true
$list.Update()

3. Using List Definition XML

Name="[list name]"
DisplayName="[list display name]"
Description="[list description]"
Type="10000"
BaseType="0"
Default="True"
VersioningEnabled="TRUE"
Hidden="FALSE"
AllowEveryoneViewItems="TRUE"
HiddenList="FALSE" />


It is important to note here that this property does not apply to all list items, but only to documents in document libraries or to attachments in list items. So you have to access this file directly for it to work ! (reference: SPList.AllowEveryoneViewItems property)

Here is the code snippet for accessing the file directly using HttpWebRequest

var fileContent = String.Empty;
//construct path to the navigation file
string fileUrl = "[full url of the file]";
//create webrequest to fetch this file!
var httpRequest = (HttpWebRequest)WebRequest.Create(fileUrl);
using (var webResponse = (HttpWebResponse)httpRequest.GetResponse())
{
if (webResponse.StatusCode == HttpStatusCode.OK)
{
using (var responseStream = new StreamReader(webResponse.GetResponseStream()))
{
//if we get the response, read the content from file as string
fileContent = responseStream.ReadToEnd();
}
}

}

Tuesday, April 15, 2014

Discontinued features and modified functionality in SharePoint 2013



Change Description

Change Reason

Workaround

Applies To

When you create a site, the Document Workspace site template is not available.

This scenario of collaborating on a document is already covered by the Team Site template.

The Document Workspace site template is no longer available as a site option.

SP2013 Foundation
SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

When you create a site, all Meeting Workspace site templates (Basic Meeting Workspace, Blank Meeting Workspace, Decision Meeting Workspace, Social Meeting Workspace, and Multipage Meeting Workspace) are not available.

Other collaboration features exist in SharePoint 2013 and Office 2013: Lync to conduct live meetings, OneNote to take notes during meetings, and SharePoint team site or My Site to store shared meeting notes.

All Meeting Workspace site templates are no longer available as a site option.

SP2013 Foundation
SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

The Organization Profiles feature is deprecated in SharePoint Server 2013. Organization Profiles contain detailed information about an organization such as teams, divisions, and other information that describes the organization’s hierarchy.

SharePoint features related to identities continue to evolve around the core concepts of users and groups, and SharePoint will not be investing further in OrgID.

Existing solutions based on Organization Profiles will continue to operate in SharePoint 2013. The Organization Profiles feature will be removed completely from the next major release of SharePoint, and solutions created by using Organization Profiles will not be supported.

SP2013 Foundation
SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

Insert Barcode command is no longer available on the ribbon. The functionality of requiring SharePoint generated barcodes to be embedded in a Microsoft Word document has been discontinued.

Feature does not meet expectations and with minimal user adoption.

Write a custom Open XML application that takes the server side barcode and injects into the Word document.

SP2013 Server

SP2013 Online

The ability to generate and embed a label containing metadata about a Word, Excel or PowerPoint document is no longer available. Settings for this feature have been removed.

Feature does not meet compliance and records management user expectations.

N/A

SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

Broadcast will no longer be supported by SharePoint servers.

Hosting and broadcasting PowerPoint presentations can be done more effectively using other applications such as Microsoft Lync 2013.

Use Microsoft Lync 2013. Also, PowerPoint will continue to support broadcast against the Office Broadcast Service (a public offering) or via Lync.


SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

Slide libraries are no longer available.

Design limitation in SharePoint Server 2013.

Users are still able to insert slides from PowerPoint files


SP2013 Server

SP2013 Online
Office Web Apps Server 2013




Change Description

Change Reason

Workaround

Applies To

The SharePoint Web Analytics system will no longer be available or upgradable to SharePoint 2013. Previous analytics will not be imported into new version.

Less than optimal performance running service at scale in large enterprises.

A new analytics system that is part of the Search feature replaces the discontinued service.


SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

Workbooks with external data connections that use delegated Windows authentication cannot be refreshed in the browser when Office Web Apps Server is used to display workbooks in a browser window. Workbooks that have credentials stored either in the Secure Store or in the connection string can still be refreshed in the browser in Office Web Apps Server.

Design limitation in Office Web Apps Server 2013.

You can still open these workbooks in the desktop Excel client program to refresh them. Additionally, an administrator can configure Excel Services in SharePoint Server to display workbooks instead of Office Web Apps Server 2013.


SP2013 Server

Office Web Apps Server 2013




Change Description

Change Reason

Workaround

Applies To

The ability to get an RSS feed of your search results in SharePoint is no longer available.

Better experience using Search alerts and SharePoint RSS feeds.

Search alerts and SharePoint RSS

SP2013 Foundation
SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

Help content added via the Custom Site Collection Help feature or HCINSTAL.EXE will no longer display in SharePoint Online.

Wikis provide a more flexible platform for the delivery of custom help content.

Help content can still be provided via wikis or other sites that you manage.

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

The Group Work site template is no longer available as a site option and the Group Work Lists feature is no longer available as a site feature.

Similar features can be used with the Team site template.

The Group Work site template is no longer available as a site option.

SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

The Personalization site template is no longer available as a site option.

Similar features can be used with the Team site template.

The Personalization site template is no longer available as a site option.

SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

Users will no longer be able to generate Microsoft Visio Pivot Diagrams directly from a SharePoint Task list.

The Assigned to field in the Task list is now a multi-valued field which is not supported by Visio.

N/A

SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

The Visual Upgrade feature is no longer available but is being replaced by a site collection upgrade feature.

The new deferred site collection upgrade preserves the user experience of the O14 version with significantly higher fidelity than visual upgrade could, including the preservation of UI and SPFeature customizations.

The Visual Upgrade feature is no longer available but is being replaced by a site collection upgrade feature.

SP2013 Server

SP2013 Online




Change Description

Change Reason

Workaround

Applies To

The Chart Web Part is no longer available.

Similar features can be used with other applications, such as Excel Services.

If you used the Chart Web Part in SharePoint Server 2010, you can continue to use it in SharePoint Server 2013. If you did not use the Chart Web Part in SharePoint Server 2010, you can use other SharePoint functionality such as Excel Services to display a chart in a SharePoint site.

SP2013 Server

SP2013 Online

SharePoint Status Indicators and Status Lists are no longer available.

Similar features can be used with other applications, such as Excel Services.

If you used SharePoint Status Indicators in SharePoint Server 2010, you can continue to use them in SharePoint Server 2013. If you did not use SharePoint Status Indicators and Status Lists in SharePoint Server 2010 you can use other SharePoint functionality such as Excel Services to create key performance indicators (KPIs).

SP2013 Server

SP2013 Online




Friday, February 28, 2014

Impersonation in SharePoint

We normally follow different approaches to update the SharePoint items or any property of web. Approaches like running piece of code with elevated privileges OR allows unsafe updates OR Uses User Tokens. As SharePoint developer we should know what happens at each approach.

RunWithElevatedPrivilages:
This is a static method in SPSecurity class. This method can be used to run piece of code with system account/application pool account access through delegation. This method runs under the Application Pool identity, which has site collection administrator privileges on all site collections hosted by that application pool. As well as this allow to access other resources like network shared location, data sources.

AllowUnsafeUpdate:
This is a property of SPWeb class. Using this property we can get or set the unsafe update behavior. At the same time the updates only acceptable in the SPWeb boundary. This is used for Gets or sets a Boolean value that specifies whether to allow updates to the database as a result of a GET request or without requiring a security validation.

UserToken:

This is another way of impersonation.  This approach can be followed if the custom code want to access data with in the boundary. For example when we use RunWithElevatedPrivilages it  grant access beyond boundary like other data sources. 

Tuesday, July 2, 2013

Upgrade custom workflow in SharePoint



Experience comes when you give a try or do something, I worked in to many SharePoint development project but my last project was troubled me during the deployment on staging server. I really interested to share the learning with all of you.

Recently we got an enhancement in one of our existing SharePoint project that has custom solution. The custom solution package contains workflows, application pages and InfoPath form. The site content was huge (25 GB), we got the site collection backup and restored on development environment and removed most of the contents to make more space on our development server. At the same time we got the requirement (enhancements) 1. Changes on one InfoPath form (adding additional fields) and one custom workflow (update in the workflow business logic and activities).

I have started the design of all enhancements but end of with major problem on the workflow. SharePoint does most of the things as per customer expectation but gives some pain to the developers and designers. Normally when we update and publish the SharePoint designer workflow, it creates a new version allow new instance on that new version and automatically not allows previous instances for new item. But this is a major issue in custom workflow. When user try to complete the existing workflow instances after updating the assembly, they may get "Task is locked by running workflow instance" error or it just hangs in "In Progress" state.. It is a very bad experience. I had read many articles which points the same issue.

If developer updates on the same DLL there are problems for existing items and there no way you can allow old workflow instances.  See the expected problems below.

  1. The old workflow DLL will be overwritten by new DLL in the GAC of deployment server
  2. If any changes done on the workflow activities then all “In progress” (old instances) workflow items cannot be completed.
  3. If changes done only on the business login then better to complete all “In Progress” workflow items before new DLL deployment.

I found a good article which explains above problem clearly, find some content and relates links below.



The following sections discuss three ways in which you can upgrade and version a workflow.

Option 1: Move all content to new site and re-execute incomplete workflows

You can create a new SharePoint site, register the new version of workflow on that site, and migrate list or document items that have workflows associated with them, omitting completed workflows. For items that have workflows pending, re-execute those workflows from scratch.

This option isn't great, because it requires data migration between the old SharePoint sites to the new SharePoint site. If your workflow fixes also modify the format of the underlying site (such as new fields in lists), the migration is nontrivial. Also, you have to re-execute your workflows that were not done, which adds burden on users who have already done their part to move workflow along.

Option 2: Code workflow so it can continue or restart all in-process workflows

For state machine workflows, you have an option of designing your state transition flow to accommodate possible future restarts. If your workflow process keeps some kind of state information in the list item or document properties, that state information is most likely a field in the list or document library. Your workflow probably expects a certain initial state value when it starts. A workflow that is already running would naturally have a different in-process state value.

If you code your workflow to accommodate any state value (not just the initial one) and during start-up jump to the code that executes that state, you can remove all completed and running workflows, remove the old workflow association with the old workflow assembly version, add a new workflow association with a new workflow version, and then re-execute all pending workflows.

Naturally, this approach puts a burden on you as a developer to add numerous conditional "re-entry/re-route" points to the beginning of your workflow. You may not want to do this extra work, or you may not be able to thoroughly test all re-entry scenarios. Also, this design is feasible for state machine workflows only.

Option 3: Run old workflows to completion with old assembly and new workflows with new assembly

You can change the mode of a workflow association to "No New Workflows," which stops new workflows from starting but allows existing ones to complete. By putting old workflow associations into "No New Workflows" mode and adding new workflow associations, you can have multiple versions of a workflow assembly running at the same time.

For example, you can have a workflow association named "MyCustomWorkflow v1.0.0.0" that is associated with version 1.0.0.0 of your workflow assembly in the "No New Workflows" mode. You can then add "MyCustomWorkflow v1.0.1.0" associated with 1.0.1.0 version of your workflow.

This is not the ideal solution either. For example, if the old workflow assembly has a bug that is not fixed, continuing to run the old workflow with the old assembly isn't helping you. Also, if the "On Item Change" event is enabled for the new workflow association, every time the item with the old workflow changes, it starts an instance of the new workflow. However, in some scenarios this approach remains the most valid.

Now, you need to deploy the new workflow assembly without removing the old version. Although stsadm.exe has the "upgradesolution" command, all it does is replace the old solution package with the new one. When the old solution package is removed, old workflow assembly will be removed from GAC as well.

To deploy a new workflow package over an old one

  1. Change the workflow assembly version.
  2. Change the workflow assembly version in the CodeBesideAssembly attribute of the Workflow element in Workflow.xml.
  3. Change the solution GUID in the manifest.xml file of your workflow project.
  4. Change the name of the .wsp solution package that is generated by package.ddfor rename the generated .wsp file.
  5. Deploy the new solution package alongside the old solution package, thus registering a new version of the workflow assembly in the GAC.
  6. Perform an IISReset command.
  7. Put the old workflow association into "No New Workflows" mode.
  8. Manually or programmatically create the new workflow association alongside the old workflow association, being sure supply a different name.

 

Tuesday, September 18, 2012

Categorize discussion Forum threads in SharePoint Or Create folder in discussion forum


Creating folders feature is not available in discussion forum list using OOTB. But this can be achieved using custom coding but quite complex. Let us see the workaround for same in OOTB. Actually the discussion forum is uses two different content types (discussion and message). The discussion content type is derived from Folder content type and the message content type is derived from Item content type.  The folder content type is represented in different way through Discussion of course you cannot see the folder image but it works as folder. So the discussion forum simply not allows user to create folders, but the discussion threads and its replies can be categorized using  some trick.
As I said before when there are two content type are used in discussion forum and the mapping is done internally in discussion forum template. If user creates a new discussion thread, by default it uses “Discussion” Content type thereafter it starts using the “Message” content type. To categorize the discussion threads try below trick.

1.       Create a discussion forum list.
2.       Add an additional column “Category”

3.       Navigate to List setting of discussion forum list
4.       Open the Discussion content type and make sure the newly created “Category” fields is available.
 
5.       Open the Message content type and click on the “Category” field.

6.       Click on the Remove button to delete the field from Message content type.


7.       Make sure that field “Category” is available only in Discussion” content type.
8.       Create new threads and pass category value.
9.       Add a reply to the existing thread and make sure that the category filed is not shown.

10.  Modify the default view and apply group by on Category field.
11.  Navigate the discussion forum home page and check is that what is expected.


Enjoy learning SharePoint :-)