Monday, June 25, 2012

word document to pdf conversion in SharePoint 2010

Points to remember:
1. Use this as a Farm Solution, Sandbox may have some API's restrictions.
2. Assume you want to add a document to a document library and that document should be converted to a PDF document.



Here is the code, for example you can add this code on ITEMADDED() event receiver of the document library.

using System.
using Microsoft.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities
using Microsoft.office.word.server.Conversions;


//verify is document added is a word document
if(properties.Listitem.Name.Contains(".docx") || properties.Listitem.Name.Contains(".doc"))
{
ConversionJosSettings jobSettings;
ConversionJob pdfConversion;
string wordfile;
string pdffile;
//Initiate the conversion settings
jobSettings = new ConversionJosSettings();
jobsettings.Outputformat = saveFormat.PDF;
Create the conversion job using the settings
pdfConversion  = new ConversionJob("Work Automation Services", jobSettings);
//Set the credentials to use when running the conversion job.
pdfConversion.UserToken = properties.web.CurrentUser.UserToken;
//Set the file names
wordfile = properties.WebUrl+ "/" + properties.ListItem.Url;
if(properties.ListItem.Name.Contains(".docx")
{
pdffile =  wordfile.replace(".docx", ".pdf");
}
else
{
pdffile =  wordfile.replace(".doc", ".pdf");
}
//Add the file conversion to conversion job
pdfConversion.AddFile(wordFile, pdfFile);
//Add the conversion job to the word automation services, conversion job queue.
// Conversion job will not take place immediately ( approx15 min process)
pdfConversion.Start();
}



Cheers!!!
Suneet

Friday, April 27, 2012

PowerShell: Total number of documents in SharePoint Site and Sub-Site

Let's say you want to know total number of document's in your SharePoint app including sub-site. Output is an excel file. Change the column in the script if you need additional columns here.



function Get-DocInventory($siteUrl, $outFileNameWithPath) {


[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$rootSite = New-Object Microsoft.SharePoint.SPSite($siteUrl)

$spWebApp = $rootSite.WebApplication

foreach ($site in $spWebApp.Sites) {

foreach ($web in $site.AllWebs) {

foreach ($list in $web.Lists) {

if ($list.BaseType -ne "DocumentLibrary") {

continue}

if ($list.Hidden) {

continue}

foreach ($item in $list.Items) {

$data = @{

"Web Address" = $web.Url

"Doc Lib Name" = $list.Title

"File URL" = $item.Url

"File name" = $item.File.name

"Title" = $item.Title

"Created" = $item["Created"]

"Created By" = $item["Created By"]}

New-Object PSObject -Property $data}}

$web.Dispose();}

$site.Dispose()}

Write-Host "File written to " $outFileNameWithPath}


function Get-Docs()

{

$siteUrl = Read-Host "Enter Site URL"

$outFilePath = Read-Host "Enter output file path (without file name)"

$outFileNameWithPath = $outFilePath.ToString() + "\uploadedDocs.csv"

Get-DocInventory $siteUrl $outFileNameWithPath
Export-Csv -NoTypeInformation -Path $outFileNameWithPath
}

#Set-ExecutionPolicy RemoteSigned
Get-Docs
 
 

Wednesday, April 11, 2012

SharePoint Migration: Migrating a page having DataViewWebPart from SharePoint 2007 to SharePoint 2010

Migrating a page having Data View Web Part from one server to a different server


I got this issue while moving the lists with MetaLogix Migration Manager. It’s a very common issue I have seen people struggling with. Time to fix these issues increases if count of DVWP increases.

By default, SharePointDesigner binds the control to the list instance using the list instance GUID. To resolve this we need to replace the GUIDs by the list name.

The steps to do this are:

1) On the attributes of the DataFormWebPart element replace the attribute ListName="{GUID}" by ListName="LIST_NAME" where LIST_NAME is the name of the list that you are binding to.

2) Go through all of the DataFormParameter elements and replace: WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{GUID}"

With:

WebPartPages:DataFormParameter Name="ListName" ParameterKey="ListName" PropertyName="ParameterValues" DefaultValue="LIST_NAME"


3) Go to the ParameterBindings element and replace

ParameterBinding Name="ListID" Location="None" DefaultValue="{GUID}"


With:

ParameterBinding Name="ListName" Location="None" DefaultValue="LIST_NAME"


This should give you a GUID free DVWP that can be placed on a page layout used by multiple sites on your site collection (as long as the name of the list is the same on all sites).

Cheers!!!

Tuesday, April 10, 2012

Knowledge Base: Let's understand SharePoint 2010 14 hive

Microsoft has replaced the "12 hive" structure that we had in SharePoint 2007 with "14 Hive" structure in 2010.




Some of the folders in 14 hive are :



Program Files\Common files\Microsoft Shared\Web Server Extensions\14 -

This directory is the installation directory for core SharePoint Server files.



Program Files\Common files\Microsoft Shared\Web Server Extensions\14\ADMISAPI -

This directory contains the soap services for Central Administration. If this directory is altered, remote site creation and other methods exposed in the service will not function correctly.



Program Files\Common files\Microsoft Shared\Web Server Extensions\14\CONFIG -

This directory contains files used to extend IIS Web sites with SharePoint Server. If this directory or its contents are altered, Web application provisioning will not function correctly.



Program Files\Common files\Microsoft Shared\Web Server Extensions\14\LOGS -

This directory contains setup and run-time tracing logs.



Other newly added folders are :



Program Files\Common files\Microsoft Shared\Web Server Extensions\Policy -





Program Files\Common files\Microsoft Shared\Web Server Extensions\UserCode -

This directory contains files used to support your sandboxed solutions.



Program Files\Common files\Microsoft Shared\Web Server Extensions\WebClients -

This directory contains files related to the new Client Object Model.



Program Files\Common files\Microsoft Shared\Web Server Extensions\WebServices -

This directory contains new wcf or .svc related files.



Note : You should rewrite and recompile any code that refers to files and resources in "12" Hive structure.For example, if you have redeployed all of your files into the "14" folder and emptied your "12" folder, any references to files under the "12" folder will not work.

Cheers!!!



Wednesday, January 25, 2012

Tired of viewing Correlation ID's searching in Log file under 14 hive

In this topic, i would like to cover how you can find out the error details in SharePoint without going into 14 hive and that big log file. There you are not sure what went wrong and you are not much intrested to find what was the issue.

Though, there are couple of 3rd party tools or freewares are available and you can very well use them but this small script will help you to identify the details with the help of the correlation id.

get-splogevent ?{$_.Correlation -eq ""} select Area, Category, Level, EventID, Message
Format-List

Change the GUID with the correlation ID you have got and that's it.

Cheers!!!
Suneet



Saturday, January 21, 2012

The possible ways: File Share Migration in SharePoint 2010


The possible ways: Migrate file shares to SharePoint 2010

Now your client wants you to suggest something for the 50 GB contents which is lying on the file system. Users are fine with that and they don’t want SharePoint or your client will be more then happy to see these 50 GB contents in SharePoint and enforce users to follow WCM standards by leveraging SharePoint.

Option 1:  You can simply set up SharePoint and let users slowly migrate to it while supporting file shares at the same time. 

Option 2: By creating sites and using the Page Viewer Web Part, the team members can both access the SharePoint site for collaboration and access the read-only file shares. The good thing about this approach is, it feels like you are in SharePoint and using it’s security model. Though it’s correct and another good thing is, if you have imposed any security on your file system contents, it will follow that. J

Option3: Get a third-party tool like Quest Software's File Migrator for SharePoint, AvePoint's DocAve File System Migrator for SharePoint, and Metalogix's FileShare Migration Manager for SharePoint.

You can then decide how you want to proceed.  If your client is good to spend few thousand dollars buy a tool and do it or force users to adopt new platform or let them be there on file system and feel them like they are in SharePoint.

Cheers!!!


Suneet

Did you ever tried - PerformancePoint Services in SharePoint 2010


PerformancePoint Services in SharePoint 2010

The Business Intelligence Center is a prebuilt site collection and site template that you can use to get started with your integration of business intelligence (BI) solutions and SharePoint 2010. Although you can build solutions into other sites or site collections, the Business Intelligence Center provides a foundation of features and SharePoint Components that enables you to quickly create a central location for the presentation of BI information.

What you should know:

PerformancePoint Services allows you to build rich dashboards that pull from a variety of different data sources (such as SharePoint lists, relational data stores, OLAP cubes, and Excel Services). Dashboards might include scorecards, reports, and KPIs (key performance indicators) that provide a summarized view of your business analytics. New PerformancePoint Services features include enhanced scorecards, reports with built-in drill-down features so you can access information quickly, and calculated metrics that allow you to create calculations that use multiple data sources. 

Server Prerequisites and Licensing Considerations

Required: SharePoint Server 2010 Enterprise, SQL Server 2005 and 2008 are supported options for Excel Services, PerformancePoint Services, and Visio Services. However, SQL Server 2008 R2 64-bit is required for Reporting Services and Power Pivot when integrating with SharePoint 2010.

We will cover the following topics to get complete understanding of the topic:

1.    Understanding and Creating a Business Intelligence Center Site
2.    What is Dashboard Designer
3.    Error….error…error…Configuring the Central Admin
4.    Creating a Data Connection with a SharePoint list
5.    Showing the data and other designer options

Creating and Configuring Your Business Intelligence Center

The Business Intelligence Center is available as a site collection template and as a site template. By default, the Business Intelligence Center site template is not available from the SharePoint 2010 front end when creating a new site, and therefore you must create your Business Intelligence Center as a site collection from SharePoint Central Administration. After the Business Intelligence Center site collection has been created, the Business Intelligence Center site template is available to create subsites that integrate with the site collection. Once created, the new site collection (or site) contains various SharePoint components and has features deployed and activated.


Creating a New Site Collection Using the Business Intelligence Center Site Collection Template:

The following steps walk through the process of creating a new site collection using the Business Intelligence Center template. Complete the following steps to create your Business Intelligence Center:

1. From within SharePoint 2010 Central Administration, click the Create Site Collections link in the Application Management section.
2. Select the web application you want to create the site collection.
3. Provide a name for the site collection (for example, Business Intelligence Center).
4. Select a managed path or use the link provided to generate a new managed path. For this example, the /sites/ managed path is used.
5. Enter the URL for the new site collection (for example, BICenter).
6. Select the Business Intelligence Center template from the Enterprise tab.
7. Enter a primary administrator for the site collection.
8. Optionally, enter a secondary administrator for the site collection.
9. Optionally, select a quota template.
10. Click OK.

Part 2: In-progress with Issue list you may face during the process.

Thursday, December 22, 2011

SharePoint 2010: Online PowerShell Command Builder Tool

Online PowerShell Command Builder Tool: The Windows PowerShell Command Builder for Microsoft SharePoint 2010 Products and Microsoft Office 365 is a Silverlight 4 application that is designed to help IT professionals and power users learn how to use Windows PowerShell for administrative tasks.


Windows PowerShell Command Builder for SharePoint 2010 Products and Office 365

http://www.microsoft.com/resources/TechNet/en-us/Office/media/WindowsPowerShell/WindowsPowerShellCommandBuilder.html

Cheers!!!
Suneet

Known InfoPath 2010 Bug: Dropdown event with Debugger....issue


Dropdown change event with Debugger crashes...you may have to logoff from machine sometime...as Task manager also stops working...looks like it strange...

Steps: Basically using 64-bit InfoPath Designer:
...

1.Create a blank form or use existing form.

2.Add a drop-down list to the form.

3.Add Choices manually or load from datasource.

4.On Developoer ribbon, click on Changed Event to generate a changed event code in VSTA.

5.Place a break point inside the field_Changed procedure. You can add some code in order for the breakpoint to stop inside the generated method when the dropdown has been changed.

6.Run the application from VSTA by clicking Start Debugging (Play icon or from Debug menu).

7.Click on the drop-down control and change the value.

This is where it will crash the system. I have searched all forums and internet but know one seems to know about this issue. If you are able to recreate this problem, please let me know.

Cheers!!!
Suneet

Wednesday, December 14, 2011

Fast Search in SharePoint 2010 - What's that you don't get in SharePoint 2010 Search

Microsoft completed the acquisition of an enterprise search company, FAST Search
& Transfer. For those who used MOSS 2007, FAST Enterprise Search Platform (ESP) could be integrated
as a separate server product, via various web parts. But as an important result of this acquisition,

Microsoft has developed FAST Search Server 2010 for SharePoint that is a fully integrated search
server engine, one that deeply supports SharePoint search functions.

For end users, FAST Search Server 2010 provides a very visual and dynamic user experience, with
the following capabilities added to SharePoint 2010 Search:

Thumbnails and previews for documents — Word and PowerPoint files in the search result
will be displayed with a thumbnail of the cover page. Moreover, PowerPoint files can be previewed
in the results list without opening the file, either with a PowerPoint client or with Office
Web Applications. These capabilities can help end users visually find the expected content.
Figure 17-3 shows an example.

View in browser — By using Office Web Applications, Office files can be opened in the
browser, without installing the thick client on the computer.

Visual Best Bets — Best Bets are well-known from MOSS 2007, and can also be found in
SharePoint 2010. But with FAST Search, you also can define Visual Best Bets, which are pictures
or videos that are Best Bets for several keywords.

Deep refiners with counts — The Shallow Refinement Panel is also available in SharePoint 2010
Search with the capability of refining results by the most important metadata. However, only
FAST Search provides the capability of result refining on metadata associated with all results.
Moreover, FAST Search provides more customization capabilities, and shows counts for each of
the refiners.

User Context from User Profiles — User Profiles might store a lot of information about each
user, and SharePoint 2010 provides some very powerful social capabilities based on these profiles.
From a Search perspective, results can be targeted by contextual user information.

User Contexts can be built by using User Profile properties, so that they make sub-groups of users, and can be associated with the following:
·         Keywords
·         Best Bets
·         Visual Best Bets
·         Document promotion/demotion
·         Sorting on any property — Each property can be the base of sorting, configured in the “Sort
by” field.
·         Similar Search — With this link for each result, users can get a new result set based on the
search of the selected search result item.
·         Broader, better language support — FAST Search supports language-specific word breaking
and stemming (via FAST lemmatization by reduction), spellcheck, and antiphrasing.
·         Richer query language — In FAST Search, custom queries can be set up using the native query
language for FAST. This provides a complete toolbox, even in the case of advanced queries.
For administrators, FAST Search Server 2010 is a highly capable and easy-to-manage search engine
that offers the following:
·         Extreme scale-out up to more than 500 million items
·         A content processing pipeline
·         Entity extraction
·         Tunable relevance ranking
·         Easy setup of User Context, Visual Best Bets, promotion/demotion
·         Easy-to-configure sorting and refinement

Cheers!!!
Suneet