Tuesday, February 9, 2010

ASP.NET MVC: Create Facebook-like search box

By Hristo Yankov
 
In today's article I will show you how to create your own Facebook-like (or LinkedIn-like) search box. If you haven't seen what it looks like, here is an example:

 
You will notice that it features: autocomplete, icon, matches what you type and when you click a result item, it takes you to the appropriate page. That's what our control in MVC will feature too. We will implement this in ASP.NET MVC2 and jQuery.


The Plan:
We will create an attribute and use it to decorate the action methods of our controllers. When we decorate an action, we will be adding metadata, such as the display name it should appear with in the search results and an optional icon. When the user types something in the search control, we will use jQuery to POST to a special controller, which will be enumerating all action methods in all controllers. While enumerating, it will be looking for a match between the search query and the metadata of each 'indexed' action method.

Implementation

Note: You can download the working demo project from here

Visit the project page here: http://yankov.us/#Projects

The Attribute
Ok, let's start with the attribute. In your Code folder (if you don't have one - go ahead and create it) add a new class and name it 'ActivitySearchAttribute'. It will have two string properties - Text and ImageUrl. Implement it like that:


This is the attribute we will be using to decorate our action methods in the controllers. That way we will mark them as 'searchable'.

Action-Method Decorations
Let's create a couple of dummy controllers, with a couple of actions in each of them and decorate them with the newly created attribute. Like this:

 

As you can see, the icon property ("group.png" in the example) in the metadata is optional. Non-decorated action methods will not be returned as search results.

The Search Controller
Now let's implement the search controller. Basically, what it will be doing is: receive a query string (e.g. "the", as in the first image of this post), get all controllers, enumerate the action method of each controller, match the 'Text' property of the 'ActivitySearch' attribute (which we use to decorate the action) and then return an array of the matches with the appropriate URL to each result. Just like Facebook. I won't paste the code here, as it is big, but you will find it in the attached sample project. The file is in Controllers and is named "SearchController.cs".

Json Response
The search will be a dynamic thing. While the user types, we will be sending a request to a controller and we will be receiving a response. We need to create a class which we will serialize to JSON and use it as a response. In your Code folder, create another class and name it 'ActivitySearchResultItem'. It will have three properties: Text, Url and Image. Implement it like that:

The Search controller will be returning an array of those, to the jQuery UI, as a JSON response.

The JavaScript / jQuery
Now, when we have the back-end, we just need to implement the front-end in jQuery and html. Note that our solution will be using a 3rd party library - jquery.autocomplete.pack.js
Additionally, we will put our javascript, in a file named "activitySearch.js".

The auto-complete jQuery plugin will take care of attaching to the text-box and submitting/receiving data to/from the back-end controller. We just need to process and format the results. When the user clicks a result, he will be redirected to the URL property associated with the result item (see 'Json Response' above). Like that:


As you can see, the jQuery code expects that if there is an Image associated with the search result it should be in the /Content/images folder.

HTML
Here is how to setup your page which will contain the search-box control.


Conclusion
Now, when you have everything in place, start the project and just type in the search box some phrase which you know will hit a result. You should see something like:


The search results are clickable and when clicked, it will take you to the appropriate action. You can optimize the whole solution with various caching settings and techniques.

You can download the whole demo project here.
Read more on this article...
Bookmark and Share

Friday, February 5, 2010

ASP.NET MVC2 - Creating a Display Template

By Hristo Yankov
 
ASP.NET MVC philosophy is "Skinny Controller, Fat Model, Stupid View". The focus of today's post is "stupid view". What does this mean? Well, it means that you should avoid writing any logic in your views. A view should be as simple as wrapping the model's properties in html tags.

If you are cornered, and must have some kind of a login in your view, it would be nice if it is neatly wrapped in a DisplayTemplate, so your code remains reusable, easy to read and maintain. What follows now is a tutorial on how to create one.


Problem: We have a Model which has a property "RemainingTime", which is an integer and represents the estimated remaining seconds of some operation. We want to neatly format this time in the view, so that if it has a value of, let's say, "5", to be displayed as "5 seconds". If it has value of "70", to be displayed as "1 min, 10 seconds", etc...

Solution: Create a reusable DisplayTemplate and use it to visualize the property.

We start by creating a new ASP.NET MVC2 "empty" project template. We don't need the default authentication and home controllers, so that would do just fine.

As a first step, let's create our Model. We'll call it "RemainingTimeModel" and will have the integer property "EstimatedSeconds". We will name the DisplayTemplate "SecondsFormatting". So we go ahead and decorate the "EstimatedSeconds" property with the UIHint attribute, passing "SecondsFormatting" (which is the name of the DisplayTemplate we want to use) in its constructor. This attribute tells ASP.NET MVC which DisplayTemplate to use by default, for this property. Your code should look like this:




Second step is to create the actual DisplayTemplate. It needs to reside in the "Views/Shared/DisplayTemplates" folder, and be named "SecondsFormatting.ascx". So, create a "DisplayTemplates" folder in your Shared views, then right click it and Add -> View. Check the 'create partial view' checkbox and give it the name we mentioned above. By default, this will create non-strongly typed ViewUserControl. We will extend this, to an integer. Open the "SecondsFormatting.ascx" file and change the Inherits="System.Web.Mvc.ViewUserControl" to Inherits="System.Web.Mvc.ViewUserControl". Now, when you refer to the Model object in this control, you are working with an integer. The Model that will be passed to this DisplayTemplate is the "EstimatedSeconds" property of the "RemainingTimeModel" model.

Now we just need to implement some logic in the control. Let's do this:



Ok, we have the model, which has the seconds property, and we have a DisplayTemplate for it. Now we jsut need to use it. For this purpose, we will create one simple controller, which creates a new instance of the model and initializes it, then passes the model to a view. In the view, we will have: Html.DisplayFor(model => model.EstimatedSeconds). Like that:

(Controller)



(View)



See how clean your View remains? No logic in there, just a DisplayFor html helper call.

We can now go ahead and try it out, with a couple of different values. It formats it accordingly. Please note that there are much easier ways to format the time and it was used here just as an example of what we should do if our view requires to have a logic. If we try with 3732 seconds, it should display "1 hours, 2 minutes, 12 seconds".

Now you know how to encapsulate your logic in DisplayTemplates and keep your main Views clean and neat.


You can download the demo project from here.
Read more on this article...
Bookmark and Share

Monday, January 25, 2010

iTFA v2.0.5

Version 2.0.5 of iTechnology Forms Accelerator is now released.

This version contains a fix for "Discover Orphan Instances" timer job issue. If you have messages like this in Event Log: Invalid object name 'dbo.iTFAFormInsts' or like the one described in this post, then you definitely need to apply the patch.

iTechnology Forms Accelerator v2.0.5 can be downloaded as a full installation package or as a patch. The patch has to be applied over version 2.0.4, while the full installation package is for users that install iTFA for first time. You can download them from our website. Packages contain installation/upgrade files and installation documentation.

Any problems can be reported in iTechnology Support Forum. Read more on this article...
Bookmark and Share

Wednesday, January 13, 2010

Issue fixed: SharePoint fields are not displayed in iTFA Form

Patch 2.0.4 of iTechnology Forms Accelerator was released yesterday. This patch fixes the issue reported in iTechnology Support Forum - Empty Form when item created by email. Similar issues were discovered with list items, created out of iTFA system from other external programs. The patch is available for download on iTechnology web site.
Patch 2.0.4 has to be applied only after v2.0.3 is installed. More information about 2.0.3 can be found in this post.

Now let's review how to install iTFA v2.0.4. The patch consists of one DLL - iTechnology.Forms.Runtime. To install it is as simple, as 1-2-3:

1. Unzip iTFA patch 2.0.4
2. Locate iTechnology.Forms.Runtime.dll and install it to GAC of all SharePoint servers where iTechnology Forms Accelerator is installed and deployed
3. Run IISRESET command for all SharePoint servers that are updated

Enjoy!

P.S: Any issues found, regarding iTechnology Forms Accelerator can be submitted in iTechnology Support Forum. We are always doing our best to help you resolve them and improve iTFA. Read more on this article...
Bookmark and Share

Monday, December 21, 2009

iTechnology has released iTFA 2.0.3

iTechnology has released an updated version of iTFA. The 2.0.3 patch includes a number of improvements such as SharePoint workflow automation fix and K2/SharePoint action integration.

We also improved the Designer by:
  • Fixing fields overlapping
  • Fixed some Service communication problems
  • Implemented Drag and Drop and User Interfaces fixes
  • Fixed boundaries issue
  • Implemented fixes for AddMinutes and AddHours calculations
The new patch is available for download on our website after registration. Note that you can apply the 2.0.3 patch only over iTFA version 2.0.2. Read more on this article...
Bookmark and Share

Friday, November 27, 2009

Anonymous access to forms - the iTFA way

There are times when your anonymous user might need to submit data to you in SharePoint. You already know the best way to create forms is ... ta-daaa ... iTechnology Forms Accelerator (I know, I know ... shame on me for the free self-compliments ...).


After the shameless self-advertising campaign you saw let's get our hands dirty; the step-by-step way:




1. IIS


Yes, you probably know this but in order to access anonymously *any* ASP.NET website, IIS needs to be configured. Here you can find how to do it with Windows Server 2003 and IIS 6. The key element to remember here is the IUSER_ComputerName account which is assigned to every anonymous visitor to your website which later on we will see how to use it in iTFA.


2. SharePoint Central Administration


Going down the drain - MOSS. Let's go to Central Administration, then Application Management and open up Authentication Providers. Here is the time to mention iTFA works best with Windows Authentication so lets enable anonymous access to the Windows membership provider.


3. SharePoint site


IIS set, provider set. Next level? Right - site. In the site where you host your iTFA-enabled forms in Site Actions menu open up Site settings and follow the Advanced permissions link. In the page's toolbar you will see Settings item and Anonymous Access subitem - click on it. Here you can enable anonymous access to the whole site or only to libraries and lists - your choice here!




4. iTFA Management site


So far, so good. 3 done, 2 to go. In order for iTFA to be sure that you are 100% percent aware which users have the required access level we have added user access functionality. You can see how to play with it by watching our short video here. Fast forward now and go to "itfa" management site in SharePoint and User Access configuration section there. Let's focus on anonymity now. Remember user IUSER_ComputerName from step 1? Here is why I have told you to keep it in mind! You need to add it to any of the 4 groups that you see in order your anonymous users to access iTFA forms. I wouldn't recommend adding this user to any other group than iTFA Users because you will be giving your anonymous guests way too much power and honestly speaking - they don't deserve it. ;-)


5. My iTFA-enabled list (document library)


Tired? Bored? Bear with me please, you are just few clicks away from having your perfectly anonymous guests access your forms!


I know the first thing you did was to watch our Hello World video (if you have missed it, you can watch it here) where you have iTFA enabled a custom list (btw the same way you do it for document library). Now let's get those anonymous users see your shiny-easy-to-use-5-minute-built new form.


Open up your list, go to Settings -> List Settings -> Permissions for this list. In the Settings menu item click on Anonymous Access. Now you get to choose what permissions your anonymous users will have - Add / Edit / Delete / View. View is selected by default but enabling any of the other options will change the list's View page with the required functionality. Let's check them all and rock on.


Here I need to mention that if you are in document library and all the other options are grayed out, there is a nice workaround to enable them. Take a look at the URL of this page you will notice that after the .aspx page there is a query "obj=%listidhere….." followed by "DOCLIB". If you change this last part of the URL from "DOCLIB" to "LIST", you will notice that you now have all of the option that you've been missing. Note that by changing the URL query in your browser you are not damaging your library in any way. You are just telling SharePoint to present you with the anonymous access settings available for a list. You can change the setting back to the default by deselecting the "Add, Edit & Delete" options.


6. Finish line


Finished! Yes, I know it took less than 5 minutes, just like with everything else you do with iTechnology Forms Accelerator... Peace of cake, huh?!
Read more on this article...
Bookmark and Share

Thursday, November 26, 2009

SharePoint Console Application Requirements

By Hristo Yankov

So you have written a Console application which is working with the SharePoint Object Model (API), but you get an error. Something similar to:
Cannot open database "WSS_Content_{GUID}" requested by the login. The login failed.
Login failed for user 'DOMAIN\User'.

Or (* see additional notes below!):
FileNotFoundException: The web application at http://some.site could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.


That's because there are a couple of security requirements you need to meet. Basically, the user who is running the console application needs to:
  • Be an Administrator on the computer he is running the app from (certainly, that would be the SharePoint server). Just add the user to the (Local) Administrators group on the machine.
  • Have sufficient rights within the SharePoint site. If you are doing some administrative tasks, you would want this user to be given "Full Control" (group).
  • Needs to have read/write permissions on the content database in the SQL server (or just make it db.owner). The database name is usually WSS_Content_{GUID}.
After you have given those rights to the console application executing user, it should run fine. And by the way, if you think you can avoid giving those permissions, by running the API calls within SPSecurity.RunWithElevatedPrivileges, you are wrong. The call itself, to SPSecurity.RunWithElevatedPrivileges would require them.

* Additional note about FileNotFound:
Although this is not covered by this article, there might be other reasons for this error. For example: Site collection not existing on this location or you need to add Alternate Access Mapping.

Well, I hope this helps someone out there,
Hristo Yankov
Read more on this article...
Bookmark and Share

Wednesday, November 18, 2009

jQuery in SharePoint

By Hristo Yankov





There are rumors jQuery might be included as part of SharePoint 2010. In an anticipation for that, today's article aims to show what the integration between SharePoint 2007 and jQuery looks like, how to use it and what are the benefits.

So what is jQuery?
jQuery is a lightweight JavaScript library that emphasizes interaction between JavaScript and HTML. It was released in January 2006 at BarCamp NYC by John Resig. jQuery is free, open source software Dual-licensed under the MIT License and the GNU General Public License. Microsoft and Nokia have announced plans to bundle jQuery on their platforms, Microsoft adopting it initially within Visual Studio for use within Microsoft's ASP.NET AJAX framework and ASP.NET MVC Framework whilst Nokia will integrate it into their Web Run-Time platform.

Simply put, it is a high performance rapid development, AJAX-enabled library on top of JavaScript.


API
There are a lot of articles and tutorials out there, on how to use jQuery in general. Here is the most essential documentation you will need - the jQuery API.

SharePoint integration
Integration between jQuery and SharePoint boils down to finding a smart way to get a jQuery reference in your pages.

Basically you can do this 'manually', which is well described here or you can use an automated integration solution (see below).

The manual approach essentially consists of two steps:
1) Deploying the libraries (js) to a location which can be accessed by the pages - that would be the LAYOUTS folder in the 12 hive
2) Loading the libraries on the pages - by modifying the master page, load the library specifically in the page you want to use it or other... It is all well described in the posted article.

The automated solution is a better one. You can get "SmartTools jQueryLoader for SharePoint" which does the integration for you. There is a good article which walks you through the installation process, so we are not going to that here. Make sure you watch the video, though.



Just try it out

If you just want to quickly try the magic of jQuery in SharePoint out, without bothering with the full integration you can do what is described here. The example in this article uses jQuery library which is hosted on Google Code (rather than in your 12 hive) and it dynamically queries the SharePoint web service to retrieve your current tasks, then visualizes them on the page. No need to develop a web part, it is just as simple as that!

You should also check this out, although for some reason I couldn't get it to work. Basically this is supposed to let you test any jQuery code, from a small 'editor' on your home page.


Benefits
So what are the benefits of using jQuery in SharePoint?

AJAX
Well, obviously it adds AJAX functionality to your SharePoint web application. You can now retrieve and visualize data asynchronously, without putting any load on the SharePoint server. It also allows you to create more appealing and faster UI.

Page elements control and flexibility
Additionally, SharePoint allows you to change content structure for subsites, lists, libraries, views, columns, content types and the Web parts, but sometimes that's not enough. Sometimes developers/designers or users need to make changes to the functionality and appearance of a SharePoint site in a way that is not allowed by the IT department. Since SharePoint Designer is usually restricted, we need an alternative way. That would be jQuery. Just to give you a concrete example of such situation, here is a guy who had to make the corners of the quick launch menu rounded.

jQuery saves development time
jQuery simplifies the way you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. To summarize it one sentence only: couple of lines in jQuery allow you to do better what you could do with over 20 lines of JavaScript.

Many other...
  • You don't have to check for null objects
  • CSS3 compliant and has a great CSS selector integration
  • Huge community which supports it. Many tutorials out there...
  • Simple and fast development
  • Lightweight!
  • etc...

Performance
jQuery 1.3 is fast. As in the "fastest JS framework out there". Here are some nice tips on how to write a fast jQuery code.


Debugging jQuery in SharePoint
FireBug is the preferred way to debug jQuery (and JavaScript in general). Here is a nice article which goes into details.


Examples
http://www.endusersharepoint.com/ - THE "jQuery & SharePoint" website.
jQuery sparklines
Showing random images in SharePoint 2007 using jQuery
Highlight SharePoint List rows conditionally
Paging large content in SharePoint using jQuery
Many other...


Read more on this article...
Bookmark and Share

Saturday, November 14, 2009

SPUG Orange County Nov 18: Forms in SharePoint

By Dmitry Ivahno

If you are in Orange County, CA or nearby, please don't miss an opportunity to visit SharePoint User Group meeting next Wednesday. The topic: "Forms in SharePoint".

This session will be of interest to both InfoPath and iTechnology forms users and designers and will help them make educated decisions when deciding which product to use. Also part of the presentation will display Forms integration with K2 workflow.

More information about iTechnology Forms Accelerator can be found here:
http://blog.myitechnology.com/2009/11/introducing-itechnology-forms.html

To register for SPUG Orange County meeting please visit its website:
http://www.officezealot.com/GroupZ/spug_ca_oc/Pages/default.aspx

Event details:
Location: QuickStart, 16815 Von Karman Ave, Suite 100, Irvine, CA 92606
Time: 11/18/2009 6:30 PM to 8:30 PM PST

Read more on this article...
Bookmark and Share

Monday, November 2, 2009

Introducing iTechnology Forms Accelerator 2

By Dmitry Ivahno

According to Gartner, 50% of the enterprises they surveyed use MOSS 2007 or WSS 3. Today millions of people have relied on Microsoft SharePoint technology for collaboration, records management, enterprise search, or other integration functions. We all know that SharePoint is both an ECM product suite and a great framework for building customized solutions. However, there's always been one problem: Once you're on the path of tailoring SharePoint to your business needs, customization of SharePoint just isn't that easy to use for non-IT professionals. Whenever you need to create a business process SharePoint Designer workflow is very limited or designed for software developers; Or you may decide to have electronic forms and use InfoPath, which is a great product. However, in case of Microsoft InfoPath, it has too many advanced features and over-complicated designer that put you in a risk of breaking a working solution. In general if you start customizing SharePoint, you're on your own.

Today we're excited to announce the next step for iTechnology Forms Accelerator: version 2 for Window SharePoint Services 3 and Microsoft Office SharePoint Server 2007.

This new version comes with everything you'd expect to find in a forms engine solution, like web-based designer, strict version control and one-click publishing process. But unlike most forms solutions, iTechnology Forms Accelerator was built based on real-life experiences we had with real clients – it is made for business users and it resolves many issues you may experience with other products.

Here are seven features that are possible because iTechnology Forms Accelerator V2 is tightly integrated with Windows SharePoint Services:

Web-based designer
When you use iTechnology Forms Designer, you browser automatically loads a Silverlight-based component. Using Silverlight 3 features makes designing forms easier. It also allows centralized no hassle deployment.

Version Control
If you work with InfoPath you probably face issues with versioning: InfoPath form templates are not versioned and you have to rely on third-party Source Version Control systems; and once InfoPath form is published to the SharePoint it starts auto-upgrade of existing instances of the electronic forms. With iTechnology Forms Accelerator you don’t have to worry about losing your changes. Each time you make a significant change a new version of the form is saved. You always can go back and load previous version. Also, once you publish your form to the list/document library, it won’t affect already created instances. Think of it as paper-based form with revision number. Just because there is a new revision you do not necessary want to “upgrade” previous filled in forms.

Easy Publishing
iTechnology Forms Accelerator integrates with any type of SharePoint document library or custom list. You start iTechnology Forms Designer from the SharePoint list you want to integrate with. When you think you are ready to publish the form you just click menu button “Publish” and publishing is done automatically. Now you don’t have to remember SharePoint URLs, manage credentials in corporate network, or worry what environment you are working now.

Windows SharePoint Services Support (WSS 3)
For those times when you do not have enterprise licenses of MOSS, iTechnology Forms Accelerator is a great alternative to InfoPath Form Services. iTechnology Forms Accelerator works with Windows SharePoint Services as well as with any MOSS editions.

Concurrent Form Design

Designing large forms with tens of Perspectives (we use term 'Perspective' which is analogous to InfoPath term 'View') can be very time consuming if you work with a form exclusively. iTechnology Forms Accelerator liberates you: now you can share form design time with other users. In contrast to other software products, iTechnology Forms Designer allows “locking” and “versioning” on smaller elements of the form.


Standard Browser Support
If you want to display your electronic forms in browsers such as FireFox, Safari, Chrome, or Internet Explorer, then iTechnology Forms Accelerator is for you. We do not have limitations on displaying web content in different browsers. It works with a simple Text Control as well as with a complex repeatable data grid with subsection.


Easy to Use

The ultimate idea behind iTechnology Forms Accelerator is to empower end-users of SharePoint (both business users and support IT personnel). We see an opportunity and challenge to make process of authoring and managing forms easy and intuitive. Here at iTechnology we spent thousands of hours designing software experiences we feel proud to share with you.

iTechnology Forms Accelerator has many other useful and important features. Here are a few:

  • Management Site. SharePoint administrators have access to many configuration settings which helps administering iTechnology Forms Accelerator in an easy manner. It also provides a comprehensive view of underlying data;
  • Workflow Integration. We integrate with all SharePoint-based workflows;
  • Straightforward data reporting. Non-SharePoint data is stored in SQL database which allows uncomplicated data retrieval and processing;
  • Embedded Rules Editor. Configure business rules instead of coding them. Test Rule allows validation of logic during the design time;
  • and many other great features.


Since there's nothing quite like seeing the product in action, we made this video to demonstrate a simple “Hello World” example:



iTechnology Forms Accelerator is free. There are no paid versions. There are no trial periods. Our clients needed this product and now we share this product with them and with you. We are being constantly asked “What is your business model? Why it is for free?”. We are proud to answer: “We want to help you. At in the same time we want people to know our company.” Please give it a try and see if you and your business will benefit with iTechnology Forms Accelerator. Of course, we provide a commercial support if your company needs it (check Technical Support page for more details).

Check out the iTechnology Forms Accelerator to learn more and browse a gallery of product screenshots.

Thank you and we always welcome comments.



Read more on this article...
Bookmark and Share

Sunday, September 20, 2009

'09 SharePoint Conference in Las Vegas, Oct 19-22

Join us for the greatest SharePoint event this year: 2009 SharePoint Conference in Las Vegas, NV, October 19-22

iTechnology will present an updated version of iTechnology Forms Accelerator. The latest version allows development of electronic forms for Sharepoint (WSS and MOSS) without reliance on Microsoft Infopath or limitations of core Sharepoint technology.

Give your business a chance to adopt Sharepoint faster and easier

For more information, visit the SharePoint Conference site Read more on this article...
Bookmark and Share

Tuesday, July 28, 2009

SharePoint Web Services Wrapper

By Hristo Yankov

Recently I noticed that a common reason for developers to seek help on the MSDN forum is related to difficulties understanding and/or utilizing the SharePoint Web Services. You can't blame the developers. It's much more convenient to work with an Object Oriented API, rather than exchanging XML messages with a Web Service. For example, take a look at the Lists.asmx -> GetListItems. Of course it's no rocket science, but it will sure save time if you could avoid dealing with the XML directly.


I spent some time researching if there is some kind of a library out there which provides 'managed' access to those Web Services. I.e. - work with .NET objects, rather than construct and parse XML elements. The closest thing I have found is this and it's totally outdated and incomplete. At least it's some reassurance to me that I am not missing the big picture and indeed, there might be people who would appreciate such framework.

So, I decided to start a project which will try to implement such .NET Object Oriented API around the SharePoint Web Services. Of course, for those corner weird cases (as well for the advanced developers), the underlying XML will still be accessible. Here is a good description of all the SharePoint services. My goal is to cover them all, eventually. I will start with the most commonly used ones.

It is hosted on CodePlex - http://spwebserviceswrapper.codeplex.com/
The project is not published yet, as there is no single line of code written yet. I will be doing this in my spare time. Once I shape it to my liking, it will become open source and everyone is welcome to contribute.

Got comments? Suggestions/Objections? There is a similar library already implemented? Please do let me know.

Hristo
Read more on this article...
Bookmark and Share

Thursday, July 23, 2009

SharePoint bug udating title of uploaded xml

By Hristo Yankov

Another interesting case...

Programmatically upload an xml file (extension should be .xml) to SharePoint document library. As soon as you upload it, try to change the Title field of the item.


So here is the code:

// We upload the file to SharePoint
SPFile file = Web.Files.Add(itemUrl, buff, true);
Web.Update();

string newTitle = "Sample Title";
SPListItem destItem = file.Item;
destItem.File.CheckOut();
// Try to change the title
destItem["Title"] = newTitle;
destItem.UpdateOverwriteVersion();
destItem.File.CheckIn(string.Empty,
SPCheckinType.MinorCheckIn);


For any non-xml extension files it works, but for xml files the Title doesn't change - it remains the same as the original name of the uploaded file. If you try doing this with another field of the item, it would work.

I came up with the following workaround:

SPFile file = Web.Files.Add(itemUrl, buff, true);
Web.Update();

string newTitle = "Sample Title";
SPListItem destItem = file.Item;
destItem.File.CheckOut();
destItem["Title"] = newTitle;
destItem.UpdateOverwriteVersion();

// Work-around start
destItem["Title"] = newTitle;
destItem.Update();
// Workaround end

destItem.File.CheckIn(string.Empty, SPCheckinType.MinorCheckIn);


Anyone has clue what's going on? Original MSDN forum thread is here.
Read more on this article...
Bookmark and Share

Wednesday, July 22, 2009

Extending SharePoint Web Part

By Hristo Yankov

Hello!

SharePoint provides a lot of different out-of-the-box Web Parts. But sometimes we wish a particular web part behaved in a little different way, or have some small extra functionality. Or we may want to implement a heavily modified Web Part, based on already existing one.

Today, I will show you how to extend the functionality of an already existing web part.


We will take for example the SharePoint RSS Viewer. It loads an RSS feed and visualizes it in a web part on a SharePoint site. One of its visible properties in the UI is the Feed URL. It's a static string and doesn't allow any kind of dynamic parameters. Example:
  • You can write: http://servername/service?Zip=92692
  • But you can't: http://servername/service?Zip=#zip_of_current_location#

Or
  • You can write: http://servername/service?IP=192.168.1.5
  • But you can't: http://servername/service?IP=#current_ip#

Those placeholders in my example are fictional, but you should get the idea of a dynamic value passed as a parameter to the service.

Our goal is to override the default behavior of the Feed URL field. We want to get to a point where we actually control how the Feed URL is being interpreted. We may want to replace placeholders with actual values, or do any other kind of adjustment of the URL, based on current and dynamic conditions. So here is the plan: we create a new web part, inherit the RSS Viewer web part and extend the Feed URL property.

Let's start. Here is how the RSS View part settings look like in edit mode:


See the RSS Feed URL field? That's what we are interested in.

Ok, start Visual Studio 2008 with the VSeWSS plugin installed. From the menu, start a new SharePoint -> Web Part project.


Give it a full trust


Change your namespace to something you prefer (for example, I will change it to HristoYankov). Rename the folder 'WebPart1' to 'RSSAggregatorWebPartDynamicParam'. It will rename all classes and files for you. In the Solution Explorer, expand Properties and open AssemblyInfo.cs. Add this to the bottom:
[assembly: AllowPartiallyTrustedCallers]

and this to the top:
using System.Security;

Your Solution Explorer should look similar to:


Right click on your project, click on Properties, go to the Debug tab and set the SharePoint site URL you will be deploying to.


Open the RSSAggregatorWebPartDynamicParam.webpart file and set Title and Description to whatever you like.

Now, after your project is setup, starts the interesting part. Let's inherit the RSS View control! What you need to do is...

Add this file as a reference - C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\microsoft.sharepoint.portal.dll. This is where the RSS View class is defined.

Open your RSSAggregatorWebPartDynamicParam.cs file and change your class from this:
public class RSSAggregatorWebPartDynamicParam : System.Web.UI.WebControls.WebParts.WebPart

to that:
public class RSSAggregatorWebPartDynamicParam : RSSAggregatorWebPart

And add this statement:
using Microsoft.SharePoint.Portal.WebControls;

Basically, we no longer inherit the basic WebPart class. Instead, we now inherit the whole functionality of the RSS Viewer web part and all of its user interface!

You can also delete this function, as we are not going to do any changes there.
protected override void CreateChildControls()

So far so good. Now let's override the Feed URL property! Add this to your class:

[DefaultValue(""),
Resources("RSSWebpart_Property_FeedUrl_Text",
"RSSWebpart_ToolPart_Group",
"RSSWebpart_Property_FeedUrl_Description"),
Personalizable(PersonalizationScope.Shared),
WebBrowsable(true)]
public new string FeedUrl
{
get
{
return base.FeedUrl;
}
set
{
base.FeedUrl = value;
}
}


And add this statement:
using System.ComponentModel;

Three things to note here:
1. The FeedUrl property is the one which handles the URL which points to the RSS feed.
2. Note the attribute on top of the property. If you don't add it, it won't be visible in the UI
3. Note the 'new' keyword. This way we hide the underlying base FeedUrl property.

Ok, now we have control over the Feed URL. What we should do, is change the way FeedUrl is being returned. Change your get to look like:

get
{
return OverrideURL(base.FeedUrl);
}


And create this function:

private string OverrideURL(string url)
{
// TODO: Process the URL
return url;
}


So, in OverrideURL we can change any way we like the URL that is set in the User Interface and then return it modified. At this point, it is up to you how to utilize this capability.

For the purpose of the example, let's just look for the string #current_date# in the URL and replace it with the current date.

private string OverrideURL(string url)
{
return url.Replace("#current_date#", DateTime.Now.ToShortDateString();
}


At the end, your code should look like:

using System;
using System.Runtime.InteropServices;
using System.Web.UI.WebControls.WebParts;

using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.Portal.WebControls;
using System.ComponentModel;

namespace HristoYankov
{
[Guid("03badfa9-53e4-401a-bc60-28db88b202ac")]
public class RSSAggregatorWebPartDynamicParam : RSSAggregatorWebPart
{
public RSSAggregatorWebPartDynamicParam()
{
}

[DefaultValue(""), Resources("RSSWebpart_Property_FeedUrl_Text", "RSSWebpart_ToolPart_Group", "RSSWebpart_Property_FeedUrl_Description"), Personalizable(PersonalizationScope.Shared), WebBrowsable(true)]
public new string FeedUrl
{
get
{
return OverrideURL(base.FeedUrl);
}
set
{
base.FeedUrl = value;
}
}

private string OverrideURL(string url)
{
return url.Replace("#current_date#", DateTime.Now.ToShortDateString());
}
}
}

Now, right click your project and do 'Deploy'. It should add a RSSAggregatorWebPartDynamicParam assembly to your GAC. When you go to your SharePoint site and do 'Edit Page' -> 'Add Web Part'

you should be able to see your newly created web part listed in the pop up. Add it to the page. Put it in Edit Settings mode and set the Feed Url to something like:
http://servername/service/Param1=#current_date#

It will be replaced by:
http://servername/service/Param1=06/06/2009 (for example)


NOTE: I just noticed this - as soon as you set the URL which contains the 'placeholder', the web part which is still in edit mode starts showing it with a replaced value (the date). I believe that the underlying value is still http://servername/service/Param1=#current_date#. So perhaps, in the method OverrideURL we should be taking into consideration if the web part is in edit mode. And if it is - just return the original parameter that was passed. Something like:

private string OverrideURL(string url)
{
if (this.NotInEditMode)
{
// Not in edit mode, perform changes
return url.Replace("#current_date#", DateTime.Now.ToShortDateString());
}
else
{
// We are in edit mode, return URL as is
return url;
}
}


I will be checking this later. As usual, you can get the full source code here.

But basically that's it. With minimum amount of code and effort, we have extended the functionality of an already existing web part, to something that serves our concrete needs.

Hope this was helpful!
Read more on this article...
Bookmark and Share

Tuesday, July 21, 2009

SharePoint Solution Hello World Tutorial

By Hristo Yankov

Hi,

In this post, I will explain to you how to create your first SharePoint 2007 ASP.NET application. We will cover what tools you would need and what are the steps to creating a SharePoint Hello World app! I will keep the article short and clear on the necessary steps to be followed.


First, let's start with the tools. You will need Visual Studio 2008 SP1 (preferably) this freely available plugin for it Visual Studio 2008 extensions for Windows SharePoint Services 3.0. It is a toolset for developing custom SharePoint applications: Visual Studio project templates for Web Parts, site definitions, and list definitions; and a stand-alone utility program, the SharePoint Solution Generator.

We assume that you have setup and you do have available a SharePoint site, on which we will be deploying our solution.

So, start your Visual Studio 2008. From the menu choose to start a new Project.


Visual Studio will show this window. Select GAC and proceed.


Your Solution Explorer would look like this, initially:


We need to create a couple of folders. Recreate the folder structure described in the screenshot below:


Right click on HelloSharePointWorld and select add new item. Select text file, but name it "Hello.aspx"


Put the following content in your newly created ASPX page.

<%@ Page Language="c#"
Inherits="Hello, SharePointHelloWorld, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=3cf44204a7ad1f1e"
MasterPageFile="~/_layouts/application.master"
%>

<asp:Content ID="Content1"
ContentPlaceHolderID="PlaceHolderMain"
runat="server">
<asp:Label ID="lblLabel1" runat="server" Text="Hello World!">
</asp:Label>
</asp:Content>

Note the PublicKeyToken value. It will be changed later. Now, create a new class in the App_Code folder. Name it Hello.aspx.cs. Your directory structure should look like:


The content of your Hello.aspx.cs should read:

using System;
using Microsoft.SharePoint.WebControls;

public partial class Hello : LayoutsPageBase
{
protected void Page_Load(object sender, EventArgs e)
{
}
}


Right click on your project, select Properties from the menu. Go to the Debug tab and set the hostname and port number of the SharePoint site where you want your project to be deployed.


Then save.

Now, right click on your project in Solution Explorer and rebuild it. Then right click on it and Deploy.


Now, open Windows Explorer and navigate to C:\WINDOWS\assembly. You should see an assembly called SharePointHelloWorld there. Right click it and select Properties.


Copy the Public Key Token (highlighted, note that it would be different for you) and click Cancel button. Now go back to your ASPX page in the project and replace the incorrect Public Key Token with the one you just copied.

Redeploy your application. Start Internet Explorer and navigate to http://[server name]:[port]/_layouts/HelloSharePointWorld/Hello.aspx

You should see something similar to:


Congratulations, you have created your first SharePoint solution. If you start the Central Admin for SharePoint and go to Operations -> Solution Management you should see a solution named sharepointhelloworld.wsp.

Let's add one more modification. Open the Hello.aspx.cs file and change it to:

using System;
using Microsoft.SharePoint.WebControls;
using System.Web.UI.WebControls;

public partial class Hello : LayoutsPageBase
{
protected Label lblLabel1;

protected void Page_Load(object sender, EventArgs e)
{
lblLabel1.Text = "Hello world! Time is: " +
DateTime.Now.ToString();
}
}



By that, we utilize the code behind to output data on the screen. Rebuild, redeploy and refresh the page.


This is a good starting point for further learning by experimenting and example.

Of course, the full code for this project can be found here.
Read more on this article...
Bookmark and Share

iTechnology Forms Accelerator Tutorial

By Hristo Yankov

Hello!

Let's talk a little bit about K2 [blackpearl]/[blackpoint]. It is a great workflow solution, but there is a slight inconvenience - it lacks a User Interface! What does this mean? Well, it means that users can use K2 to create a workflow process, but when it comes to user interaction with this process, someone has to develop an ASP.NET page or Windows Forms application, to receive the user input and update the process. Even if you buy the expensive InfoPath, you may still need to do some coding. Wouldn't it be cool if even your business users could create a user interface for K2 workflow, without coding, all in one single environment?

Also, K2 is not too convenient for creating task-level workflows (many sequential tasks for the same user). Sure, you can queue multiple Client Events one after the other, but user has to click on his task items and load a new page for every one of them. It would be awesome if the user could stay on the same page and just complete his tasks, one after the other, with a single click.


In this blog post, I would like to show you how to use our very own tool - the iTechnology Forms Accelerator (iTFA)! It addresses both of the problems described above. I will demonstrate, step by step, how to create a user interface for a task-level workflow, from within the same environment where you create your K2 process - Visual Studio. Basically you create a form definition for the interface, while you create your K2 workflow. Then, when users open their worklist item(s), the definition is rendered as a web page. To see how it works, just follow the tutorial below.

We will create a simple task level workflow, for a fictional company which receives calls and delivers products. The process will go this way:
  • Call center - Receives a new call and logs the client details
  • Call center - Either logs what the client orders, or marks the order as 'canceled' (if user changed mind during the call)
  • Packing Department - They receive the order
  • Shipping department - They receive the order (package ID) and address to ship to
Assuming you have properly installed iTFA, let's fire up Visual Studio 2005 and create a new K2 Process.


We start with a fresh new (and empty) process. Let's rename the process file to 'iTFATest1Process.kprx'.


First, let's integrate the K2 process with iTFA. In your toolbox, there should be an 'iTechnology Forms Accelerator Process' under the 'Process Wizards'.


Drag&drop it on the canvas. It will start a wizard. The first page is just a welcome.


Click Next and you will see:


The misc K2 field 'Form Engine URL' was created during the installation. It is supposed to store the URL to the forms rendering page. Basically, this is the page your users will be opening later (to work on their tasks), after you deploy your process. Here you have the chance to override the value, if you need to. You can just press 'Next'.


Here, you can setup the layout of the page the users will be presented with, when they open their task. It contains three different sections:
  • History - in this section of the page, the user will see who and when finished what task in the current workflow
  • Summary - Visible in all activities (tasks) of the workflow. You can use to show the same fields to all users of the workflow.
  • Task - The area of the page which shows the current task details
So, you can arrange those parts as you like and you can make some of the parts start minimized (by clicking the icon on the left of the 'x' in the part). Note that you can select a different layout from the left side of this window (above the Set Layout button). For the purposes of this demo, i will change the layout to three horizontal parts, one under the other.


After doing it, note that the layout is empty. We need to drag and drop the web parts (located on the lower left) into the different sections of the layout. Let's put the History on top, Summary in the middle and Task (current) in the bottom one. Just drag&drop them in the appropriate sections.



Once we are satisfied with the layout our users will see, click Next.



This is where you can setup the Summary section. I would suggest to leave it empty for now. Later, when we know exactly what K2 fields we need, we will come back to this screen and set it up. Just click Next and then Finish to finalize this integration wizard.

After this is done, you should see the iTechnology Forms Accelerator Process integration icon, in the upper right corner of Visual Studio. We will click it later, to get back to this Process wizard and setup the Summary web part.


Note: The process we just finished, could have been started also by drag&dropping your first iTFA Client Event activity on the canvas. To avoid confusion, we did it the 'normal' way. Ok, now we can create our first user task (receive a call) in the workflow, which will be powered by iTFA user interface. There is an 'iTechnology Forms Accelerator Event' in the 'Event Wizards' section of Toolbox toobard.


Drag&drop it on the canvas. It will start another wizard. The first page you will see is the overview/welcome page.


Click Next. On this page, you give a name of your activity. Let's name it 'Receive a call'.


Click Next. Here, you can set summary and details of the task. They will be displayed to the user who is performing it, so you can use it to provide instructions.


Click Next. On this page of the wizard, you have to make a choice regarding the user interface of this particular task.


It can either:
No layout - no user input specific for this task, just Actions the user can take and Summary of the page.
New layout - we will specify new layout (fields) for the task
Copy layout - to copy the layout of another task. It is not available to us, as of right now, because we don't have other iTFA tasks in the workflow, this is the first one.

Let's go with 'New layout'. Here is the default new layout, which you should modify according to the needs of the current task (log a call).


As yo can see, the user input fields can be grouped in different 'sections'. Let's rename our default section to 'Client Information', by clicking the 'Edit' button of this section. We will also change the number of columns within the section to one (one field per row in this section).


And here is how it looks like after the change:


Ok, now let's think what K2 fields we need, to store the client information. Let's say:
  • Client Names - Names of the person who called us
  • Company Name - Name of the company this person works for
  • Company Address - Address of the company
  • Phone Number - Phone number we can use to reach the person/company
Using the K2 Object Browser, you can create those fields, as strings, on Process level.


We will add all of them as strings. Here is a screenshot after adding the K2 fields to the Process.


Now we can drag&drop any of those fields to our canvas on the left. Let's add all of them in the first (and only, for now) section. Drag&drop a field we created on the orange are of the section.


Let's add a new section to this task, of 2 columns. Click on the 'Add New Section' black button. Name it 'Other'.


We will add two more fields to it:
  • Special Notes - where user can input any special notes about the client
  • Referred By - specify how client found us

First, create the fields as we did before, then drag&drop them on this section.


Couple more things and we are done with this page. Let's make the fields in the first section required. Click on their 'Edit' buttons and mark them as required.


We also want to render the Company Address and Special Notes as multiline.


Let's render the 'Referred by' field as a dropdown with three different values to choose from:


And we are done, click Next. You are brought to the Actions screen. It initially has no actions. If you click Next, it will ask you to create the default 'Task Completed' action. Let's create two actions. One of them will be 'Take order' and another one 'User canceled'.


Click Next. You have to specify a 'destination' of the task. In other words - who will be performing it? Let's set it to the process originator, because it is the call center who will be starting a new instance of the process every time a client calls.


Then click Next. On the following page you can indicate that the user should receive an email notification when the task is available to him. In this case, it is not necessary so we don't check it.


Click Next and then finish. Now link the 'Start' process activity to the activity we just created. Create an empty server event activity and name it 'End'. Link the user canceled action to it. You should see something similar to:


Now, let's create our second iTFA activity in the workflow, which is the 'Take order'. Again, drag&drop the 'iTFA Event' on the canvas and follow the wizard. Let's create the following UI for this task:


Note that the K2 field behind Quantity is integer. Ok, let's adjust those values. We will make all of the fields required, Products and Shipping method will be dropdowns and we will display the 'Products' K2 field as 'Selected Product'.


Shipping method:


And we are done with the UI for this task. For actions - add 'User canceled' and 'Send to packing'. Destination should be the same - process originator. The workflow now looks like:


We need to create a task for the Packing department. Do the same drag&drop, this time, let's copy the layout from the 'Take order' activity.


We will see the same layout as the Take order activity. Delete the Shipping section, as it is not relevant in this case. In the Products section, make the fields 'read-only'.


(Quantity readonly)


Then create a new section called 'Packaging' and add a new field in it - Package ID, which will be required to be populated by the user executing this task. In our fictional company, it will indicate some inventory or storage number.

The end result should look like:


We need only one action for this task - Send to Shipping. Destination should be some guy in the Packaging department, but for our convenience, let's set the Originator again. Now your workflow looks like:


Create a task for shipping, where they see the Client Info, Shipping preference and Package ID. Let's copy from 'Client Information' again. Make all fields readonly. User interface should look lie:


Make Destination be the Originator again and Actions should be 'Shipped', linked to the end of the workflow.

And here is our workflow finalized:


Let's return back to the 'Summary' section and edit it. Click the iTFA integration icon and go to the last page of the wizard. Add any fields you would like all users to see, to the Summary canvas. Rename the section to 'Info'.


Now we just need to deploy it. Click the 'deploy' button which starts the wizard and just click Next and Finish.


If there were other users (other from Originator) in the process, make sure you give them rights to the process in the K2 Workspace.

You can now start a new instance of your process from the Workspace or you can open our page (same one as the value of Form Engine URL):
http://[servername]/ITFA/ITFARender.aspx?ProcName=iTFATest1\iTFATest1Process&Folio=TestFolio
You can use that capability to incorporate it into an existing site or another software. For instance, your call center employees could start a new call log by clicking a link in their portal.

So, let's review what the users will see. Here is the first screen, where the user logs the call:


As soon as the user populates the information and clicks on the Take order action (link on the bottom of the page), he sees the following screen:


Here the call center logs the product the user is interested it and quantity. We then send it to Packing. Here the Packing guys see what they need to pack and then assign an ID to the package, which will be used by the Shipping department.


They send it to Shipping. Here, the Shippers see the Package ID (so they can find it in the warehouse), see the address to ship to, special notes and shipping method.


And that's it! Shipper finishes the task, workflow is complete.

Benefits?
  • We built user interface for three different departments of the company without even writing a single line of code.
  • We did it without leaving the Visual Studio environment.
  • We did it while we were building the workflow itself.
  • This whole tutorial can be complete for less than 10 minutes. How many days/weeks would your IT department need to do it the 'regular' way?
  • Many other...
This was a really short look at some of the capabilities our product offers. Interested? Contact us at our web site to get your copy now! We can also do an online demo for you.

You can also check out our videos on YouTube.

Thanks,
Hristo Yankov
Read more on this article...
Bookmark and Share

Friday, July 17, 2009

SharePoint 2010 overview

By Hristo Yankov

SharePoint is a collection of products and software tools by Microsoft that mainly provides collaboration functions, process management, searching and document management. Currently, the most popular version is SharePoint 2007. At this very moment Microsoft is working very hard on releasing the next version of the product - SharePoint 2010. This article will try to cover areas such as: what new features will be there, what changes from developer's standpoint, what are the requirements, release date and others.

Naming
The product is no longer code-named "14". The official name is Microsoft SharePoint Server 2010. The 'Offfice' part of the name finally drops out. The Office brand will no longer include Server side components (such as SharePoint). It now clearly refers to the client applications, such as Word, Excel and etc.

On a separate note, Exchange 2010 will be shipped separately of Office (beta is out already).

New Features
  • Groove (document collaboration application, acquired by Microsoft) is now being renamed and transformed into Microsoft Office SharePoint Workspace 2010.
  • SharePoint 2010 is not going to support Internet Explorer 6 (awesome). However, it will be supporting Firefox 3.x on Windows and perhaps even Firefox 3.x and Safari on non-Windows platforms.
  • Master Data Management (MDM) will be integrated with Office 14.
  • SharePoint 2010 will be able to interact with other CMS systems through CMIS.
  • You will be able to map SharePoint lists directly to database tables, which will provide great performance and scalability, especially on large lists.
  • There will be Silverlight support and maybe AJAX!
  • SharePoint Designer will support saving workflows to re-use for provisioning.
  • BDC might support Updating and Inserting data
  • Faceted Search
  • FAST Search for SharePoint. A new version of FAST Search for SharePoint at a lower cost.
  • "Web edit" - "Microsoft has made it much easier for users to customize their own sites in SharePoint 2010. A new feature called Web edit allows site owners to edit their sites almost as if they were typical Office documents, making it easier for them to carry out common Web editing tasks like uploading and changing images or editing text."
  • Other user-focused upgrades include the ability to use Office themes in SharePoint, for example by customizing a team site with the color palette of a SharePoint slide deck.
  • Read Visio documents in SharePoint
  • Improved administrative capabilities with a dashboard that uses the ribbon interface
  • Set of tools to monitor server farm health and data performance
  • Standardized UI across all Office products, browsers, mobile devices
  • Open API support

The free (and light) WSS version of the product will still be available, although there is no much information regarding it. Microsoft announced that it will get a lot of new features and will be a "great release".


Developer tools
So, having said all that, what changes from the developer perspective? Is our life going to become easier, or even harder?

Microsoft announced "deep support for industry standards" and the main development tool will be Visual Studio 2010. It will ship with comprehensive support for development in all SharePoint areas - Web parts, features, solutions, content types, etc.

Deploy and debug from VS
You should be able to build, deploy and debug SharePoint applications directly from Visual Studio! If this is true, it will save us a lot of time!

Also, there will be a new Server Explorer window within VS, which we will use to explore SharePoint objects such as: Sites, Lists, Documents and other.

The Feature Designer embedded in Visual Studio 2010 will provide a detailed look at all the components of a Feature.


Package Explorer will provide you a WYSIWYG view to your package. You should be able to re-arrange items within the package by drag&drop!

There is extended support and integration of the Team System, if you are into this kind of a Source Control.

Requirements
It is a good idea to start getting prepared for this release of SharePoint, as it has very specific system requirements.
  • SharePoint 2010 will be 64-bit only
  • SharePoint Server 2010 will require 64-bit Windows Server 2008 or 64-bit Windows Server 2008 R2.
  • SharePoint Server 2010 will require 64-bit SQL Server 2008 or 64-bit SQL Server 2005.
  • As mentioned, IE 6 won't be supported.
Out of the article:
So, what can you do today to get into the best shape for SharePoint Server 2010?
1. Start by ensuring new hardware is 64-bit. Deploying 64-bit is our current best practice recommendation for SharePoint 2007.
2. Deploy Service Pack 2 and take a good look at the SharePoint 2010 Upgrade Checker that’s shipped as part of the update. The Upgrade Checker will scan your SharePoint Server 2007 deployment for many issues that could affect a future upgrade to SharePoint 2010.
3. Get to know Windows Server 2008 with SharePoint 2007, this post is a great starting point.
4. Consider your desktop browser strategy if you have large population of Internet Explorer 6 users.
5. Continue to follow the Best Practices guidance for SharePoint Server 2007.
6. Keep an eye on this blog for updates and more details in the coming months.

And here are two interesting Q&As:

Q: Why are you only supporting the 64-bit versions of SQL Server 2005 or 2008 for SharePoint Server 2010?
A: This decision was based on our current test data for SharePoint Server 2010 and real world experience from customers running SharePoint Server 2007 with 32-bit SQL Server. SharePoint performance and scalability can benefit significantly from 64-bit SQL Server and the throughput increases are significant enough for us to make the difficult decision to only support SharePoint Server 2010 on 64-bit SQL Server 2005 or 2008. It has been our strong recommendation for some time that SharePoint Server 2007 customers take advantage of 64-bit SQL Server due to the inherent performance and scale benefits it can provide.

Q: Where can I find more information on the advantages of 64-bit hardware and guidance on how to migrate SharePoint from 32-bit to 64-bit.
A: These two TechNet articles are a good starting point;


Release date
According to Chris Capossela (senior vice president of Microsoft’s Information Worker Product Management Group) SharePoint 2010 will enter a technical preview in the third quarter of 2009 and will release to manufacturing in the first half of 2010.

Beta
Microsoft announced that it is now testing the software in an invitation-only technical preview, with a public beta to follow later this year. It focuses on a number of its enterprise customers and target specific enterprise deployment scenarios.

So, there is still some waiting to be done. But waste no time, instead, start preparing your 64-bit environments!
Read more on this article...
Bookmark and Share

Wednesday, July 8, 2009

SharePoint regional settings double value bug

By Hristo Yankov

Here is an interesting one...

I had to set the regional settings of my SharePoint site to Hungarian, so the DateTime fields get localized properly. This has been discussed previously here.

However, I started experiencing problems with the double values. Explanation by example:
(myField is of type SPFieldNumber)


double myDouble = 123.45;
myField.DefaultValue = myDouble.ToString();

Basically, I am trying to assign the value of a type double variable as the default value of my SharePoint field (which I am about to render).

At this point, when I check (using Quick Watch in Visual Studio) the value of myField.DefaultValue it shows 123,45 (which is ok, for the localization I am using). However, myField.DefaultValueTyped shows 12345. Looks like SharePoint is ignoring the fact that the site is localized and does not consider ',' to be in the role of a '.'

The solution I came up with is:
double myDouble = 123.45;
myField.DefaultValue = myDouble.ToString(CultureInfo.InvariantCulture);

Perhaps it is not the best, but at least the output now is:
myField.DefaultValue = "123,45"
myField.DefaultValueTyped = 123.45

Which is what is expected! Let me know if you know of a better way!
Read more on this article...
Bookmark and Share

Tuesday, July 7, 2009

stsadm command line error

By Hristo Yankov

There is a common problem with stsadm being executed from the command line. For example, you run:
stsadm -o installfeature -name [featurename]

And you get "Command line error." in the console. It is because you have copy/pasted the command from your browser or somewhere else. There is a problem with the encoding.

Solution: Type the command in the console window, don't paste it.

Hope this helps. Read more on this article...
Bookmark and Share

Monday, July 6, 2009

Installing WSS/MOSS on Windows 2008 x64 Step-by-Step guide

By Pako Simeonov

As developers we often have to use SharePoint environments that were already prepared for us by the infrastructure guys of the company we work for. Unfortunately sometimes they just take the shortcut and install the environment (especially the DEV one) the easiest and fastest way they know about - installing it in a single server mode, which uses local accounts. This unfortunately works good only for simple scenarios and in most of the cases the solutions we are implementing doesn't go in that category, since we have integrations with different systems which are on different servers. Here are couple of scenarios:

1. There is a dedicated SQL server where we store our configuration and content databases.
2. We have timer jobs that are accessing external systems to synchronize data between them and SharePoint. As we know in this case the code is executed under the SharePoint Timer Service account.
3. We need to use Kerberos authentication instead of NTLM in order to pass the credentials of the user to service that is running on another server.
4. Crawling content sources

Here is a step-by-step guide for installing WSS 3.0 by using domain accounts instead of local ones. I used Windows 2008 x64 virtual machine, so I can revert back to a particular snapshot:

  1. Install IIS - WSS 3.0 requires IIS where the central administration site will be initially installed and after that all the SharePoint web applications. You can find some more details of how to do that here Installing IIS 7.0 on Windows Server 2008.
  2. Download WSS - Download Windows SharePoint Services 3.0 x64 with Service Pack 2 from the microsoft web site.
  3. Choose the installation - When you run the installation you need to select the Advanced option.
  4. Choose the Server Type - The Web Front End option should be selected
  5. Specify configuration database settings - Since all the servers in the farm will share one configuration database in the farm mode we have the chance to select a database for it on a different server, which is what we want in our deployment scenario. At this point we need to create an account that will be used to connect to the configuration database. Since our database is on a different server we must create it as domain account. A good practice is to call this account SPConfigAcct, so you know what it is being used for. Here is how the wizard page looks like after the needed information was provided:
  6. Configure SharePoint Central Administration Web Application - at this step the port number of the central administration application should be selected and the type of the security provider - either NTLM or Kerberos. The Kerberos provider is recommended but it requires some additional configuration by the domain administrator - the right Service Principal Names (SPNs) should be added.
  7. Complete the configuration - if the configuration was completed successfully you should see the following wizard page with overview of the WSS configuration:
  8. Configure Windows SharePoint Services Search service - two new domain accounts needs to be created at this point. One account for the search service itself (SPSearchAcct) and another one which will be used by the search service to access all the content (SPCrawlAcct). In order to configure the search service you will need to go to Central Administration -> Operations -> Services on Server: As you can see initially the search service is stopped since it is still not configured. When you select the search service you will be able to provided the needed information. At this point you need to provide the two accounts - SPSearchAcct and SPCrawlAcct that was previously created. NOTE: when you provide the accounts make sure that you also add the domain name. Otherwise you will not be able to start the search service and an error will be shown.
  9. Setup the outgoing e-mail settings
Now that we have our WSS installed we can create our web application that will contain our site collection with the site which we want to use for our development.

  1. Create the new web application - to create the new web application you need to go to Central Administration -> Application Management and select the Create or extend Web Application:After you click on the Create a new Web Application you will be presented the screen where you have to provide the settings for the new web application:
    You can change the port on which the web application will be created at, which in our case is 9000. We need to create a domain account for the application pool of our new web application. Following our naming convention we can name the account SPContentPoolAcct and provide the name (together with the domain name) and the password in the Application Pool section. For the database server where the content database will be created we select the same sql server as we did for the configuration database. By default the database name created for the new web application has the name WSS_Content_{GUID}, but I found out that it is much more easier to give it a more meaningful name, which will help us find it faster in the SQL server. A good name is WSS_Content_{Port Number}.
  2. Create Site Collection - once the web application is created we need to create the site collection together with the root site.
At this point you need to provide the site template that will be used for the root site and the account of the site administrator, who will be responsible for managing the site.
At this point we have our site created and ready to accept all the stuff we create as devel0pers for it - willing or not.

As a good practice I would recommend you to create sub site where you will be provisioning your components. It has some benefits that can save you some troubles later. Here are some of them:
  • if you are creating custom SharePoint application in most of the cases you will use the API, being it from the custom pages you create or from external applications that are connecting to the particular SharePoint site. I've seen couple of cases when the developers are using the root site for their application and when it comes the moment to move it to production where it should be in a subsite it happens that it is not working correctly.
  • sometimes it happens that there is something bad in your site as a result of improper provisioning, missing files, etc and it is much faster to recreate everything than trying to figure out what exactly is wrong. Having your application provisioned to a subsite will give you the opportunity to only delete this particular subsite. If you delete the root site you will delete all its child sites, which is not what we want to do.

Read more on this article...
Bookmark and Share