6/2/09

Unique Constraints in SharePoint Lists or Libraries

Sometimes it's necessary to have an unique column with users, locations, etc. SharePoint don't offer this possibility and you have to develop one if you need this functionality.

Codeplex has created a policy for resolve the problem.
You must install and deploy the UniqueColumnPolicy.wsp file. This feature is deployed as a farm-level feature and should be active when you deploy it. If you need to activate or deactivate the policy, go to Operations>>Manage Farm Features in the Central Administration site.






Once you have applied the policy to the column, if you try to insert a repeated user you must see a message like this:









5/2/09

Redirect to other URL when closing an Infopath Form

When we have a web-browser enabled Infopath form you would have the need to redirect after close this form. In fact this possibility is enabled in the submit button, which redirects you to the original library where form is in. If you want to change this URl you must edit the form and copy the original URL. For example:

https://misharepoint/_layouts/FormServer.aspx
XsnLocation=/FormServerTemplates/nombreFormulario.xsn&
Source=https://misharepoint/Paginas/Default.aspx&DefaultItemOpen=1

You must change the URL of the 'Source' attibute and put the new URL:

https://misharepoint/_layouts/FormServer.aspx XsnLocation=/FormServerTemplates/nombreFormulario.xsn& Source=https://misharepoint/sitio/Paginas/prueba.aspx&DefaultItemOpen=1

&DefaultItemOpen=1 is very important. This attribute allows the form to be opened in a web browser.

CASE A:

One of the problem you can find is that this cheat only works in a same Site Collection.
If you want to put a foreign URL (like http://migueltabera.blogspot.com) you must create and ASPX file (
Redirection.aspx) in the path:

C:\Program Files\Common Files\Microsoft Shared\Web server extensions\12\TEMPLATE\LAYOUTS

and add this code:





After add this code you are enable to put this ASPX direction in the 'Source' attribute of the URL Form

https://misharepoint/_layouts/FormServer.aspx XsnLocation=/FormServerTemplates/nombreFormulario.xsn& Source=https://misharepoint/_layouts/redireccion.aspx&DefaultItemOpen=1


CASE B:

If the form is inside a frame you have to change the ASPX 'redirector' and put this javascript code:









Information extracted from the Miguel Tabera's Blog.

WSS 3.0 templates and MOSS 2007 Templates

WSS 3.0 Site Templates

Team Site: This is the standard site template, with some precreated lists and libraries: Shared Documents, Announcements, Calendar, Links, Tasks, and Team Discussions.
Blank Site: The same type of site as a team site, except that there are no precreated lists or libraries. The only thing displayed on this "blank site" is an image Web Part that shows the WSS logotype.
Document Workspace: This is a special type of site that mostly is used by a team to collaborate on a specific document. Mostly, this type of site is created using the quick menu for a document or directly from within MS Office applications.
Wiki Site: This is a new site template for WSS 3.0; use this template to create sites where users can read and add information in a very informal way. Common uses for wiki sites are capturing brainstorming ideas, building a support center knowledge base, and building a general knowledge base.
Blog: A blog is a site where you share your ideas, comments, and often tips and tricks. Usually, there is a single person who is responsible for a blog site, but it may also be used by teams that want to share information with other users.
Basic Meeting Workspace: This type of site is normally used to capture details and information for a meeting. It contains four precreated lists: Objectives, Attendees, Agenda, and Document Library. This type of site is called a workspace, and it is still a common WSS site. This site is most commonly configured when booking a meeting using Outlook 2003 or 2007, although you can create it manually.
Blank Meeting Workspace: This is similar to the basic meeting workspace, except that it only has one precreated list: Attendees. Use this template when you want to create all lists manually. The Attendees list is special, since it will automatically be populated by all users invited to an Outlook meeting.
Decision Meeting Workspace: This site template contains the following precreated lists: Attendees, Objectives, Agenda, Document Library, Tasks, and Decisions.
Social Meeting Workspace: This template has three pages created by default: Home, Discussion, and Photos. This site template also contains these lists: Attendee, Directions, Things to Bring, Discussion Board, and Picture Library. It also displays an image Web Part. This type of site is often used to discuss social events, such as Christmas parties and Birthday celebrations.
Multipage Meeting Workspace: This site template is very similar to the social meeting workspace, with its three pages. The difference is the number of lists: This template only has Attendees, Objectives and Agenda. Two of the three pages are empty, and you are supposed to add lists to them.

MOSS 2007 Site templates

Collaboration Portal (on the Publishing tab): A site template typically used for creating intranet sites. It also creates a number of subsites, such as a Document Center, a News site, a Reports site, a Search Center, and a Site Directory. This site template is only available when creating a top site (a new site collection).
Publishing Portal (on the Publishing tab): A site for Internet-facing web, or an intranet for a large company. This site only contains one subsite: the Press Releases site. This site is also only available when creating a top site.
But there are more site templates that come with MOSS; most of these are the same as the subsites that are automatically created when selecting the Collaboration Portal site template. They can be used when you need to create more News sites, or Document Centers. These site templates include the following:
Document Center (on the Enterprise tab): A site template typically used for creating a site containing documents available to all users in the organization.
Records Center (on the Enterprise tab): A site template used for creating a site where users can store records. A given Records Manager can use a routing table to control where incoming records are stored. This site contains some special features. For example, once a record is stored, it cannot be changed by the user again.
Site Directory (on the Enterprise tab): A site that lists and categorizes links to other SharePoint sites. You can also use it to create links that will be listed by the Tasks and Tools Web Part.
Report Center (on the Enterprise tab): A site template used for creating sites that contain reports, presentations, key performance indicators (KPI), and dashboards. Typically, it is used for presenting Business Intelligence information.
Search Center with Tabs (on the Enterprise tab): A site used for searching information. This site allows you to create extra tabs beyond the default All Sites and People. You can also customize the search Web Parts and the search result Web Parts on this site.
My Site Host (on the Enterprise tab): This site will typically be used to host personal sites for users, also known as My Sites. Note that this site can only be created once per Shared Service Provider.
Search Center (on the Enterprise tab): This site template is similar to the Search Center with Tabs, except that it does not have tabs.

4/2/09

Force execution of "expiration policy" in MOSS 2007

When you develop actions (or workflows) that should be executed when an expiration policy occurs you need to test them, but Expiration Policy job only is scheduled to run once a day.

You can execute this C# code to force the execution of the job:

using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

using Microsoft.SharePoint.Administration;

namespace RunExpirationPolicy
{
class Program
{
static void Main(string[] args)
{
foreach (SPService srv in SPFarm.Local.Services)
{
foreach (SPJobDefinition job in srv.JobDefinitions)
{
string jobTitle = job.Title;

if (jobTitle == "Expiration policy")
{
job.Execute(Guid.Empty);
}
}
}
}
}
}

You can use it to force any moss job. You only have to change the name of the job in the IF condition.