Thursday, November 10, 2011

Creating a Site Context Search Box that Uses SharePoint Portal Server Search Results

When you create Microsoft Windows SharePoint Services sites, Meeting Workspace sites, and Document Workspace sites that are linked to Microsoft Office SharePoint Portal Server 2003 portal sites, you may want to use the search engine of the portal site to search all your sites. When you use Microsoft SharePoint Portal Server Search service (SharePointPSSearch), you get the added benefits of a consistent user interface and the ability to search multiple levels of the site hierarchy with one request.
The following table lists and describes the items available for search when you use either the search capability in Microsoft SQL Server (on which Windows SharePoint Services is based) or the search capability in SharePoint Portal Server 2003.

Packaging and Deploying Web Parts for Microsoft Windows SharePoint Services

Web Parts are more than just the assemblies into which they are compiled. A Web Part may have class resources such as images, Microsoft JScript® files, and Help files. These files may also be localized and deployed in locations that are different from the location of the Web Part. Additionally, the Web Part must be added to the SafeControl list for the specific virtual server before users can take advantage of its functionality.
Prerequisites
  • Familiarity with Microsoft Windows® SharePoint™ Services and/or Microsoft Office SharePoint Portal Server 2003
  • Knowledge about how to create a Web Part
  • Familiarity with the Web Part infrastructure

Creating Event Log Messages for a Document Library in Microsoft Windows SharePoint Services

The following table describes the events for document libraries provided by Windows SharePoint Services for which you can enable logging.
Table 1. Document library events
EventDescription
Cancel Check OutChanges made to a checked out document are undone.
Check InA document is checked in to the document library.
Check OutA document is checked out from the document library.
CopyA document in the document library is copied.
DeleteA document is deleted from the document library.
InsertA new document is saved to the document library.
Move or RenameA document is moved or renamed.
UpdateAn existing document or the value of a custom column in the library is edited.

ASP.NET and SharePoint Security Policies

You can specify a level of trust that corresponds to a predefined set of permissions for ASP.NET applications. By default, ASP.NET defines the following trust levels:
  • Full
  • High
  • Medium
  • Low
  • Minimal
With the exception of the Full trust level, all trust levels grant only partial trust to the application folder of a virtual server instance. For more information on the ASP.NET trust levels, see Code Access Security for ASP.NET.
Additionally, Windows SharePoint Services defines two trust levels of its own:
  • WSS_Minimal
  • WSS_Medium
The trust levels extend the Minimal and Medium trust levels of ASP.NET for Windows SharePoint Services. The trust levels are defined in security policy files, wss_minimaltrust.config and wss_mediumtrust.config. By default, Windows SharePoint Services stores these files in the following location:
local_drive:\Program Files\Common Files\Microsoft Shared\web server extensions\60\config
By default, when you extend a virtual server with Windows SharePoint Services, Windows SharePoint Services sets the trust level to WSS_Minimal. This helps provide a secure trust level in which assemblies operate with the smallest set of permissions required for code to execute.
The following table outlines the specific permissions granted with the custom security policy files included with Windows SharePoint Services.
PermissionWSS_Medium trust levelWSS_Minimal trust level
AspNetHostingPermissionMediumMinimal
EnvironmentRead: TEMP, TMP, OS, USERNAME, COMPUTERNAME
FileIORead, Write, Append, PathDiscovery:Application Directory    
IsolatedStorageAssemblyIsolationByUser, Unrestricted UserQuota   
Reflection      
Registry      
SecurityExecution, Assertion, ControlPrincipal, ControlThread, RemotingConfigurationExecution
Socket      
WebPermissionConnect to origin host (if configured)   
DNSUnrestricted   
PrintingDefault printing   
OleDBPermission      
SqlClientPermissionAllowBlankPassword=false   
EventLog      
Message Queue      
Service Controller      
Performance Counters      
Directory Service
SharePointPermissionObjectModel = true
WebPartPermissionConnections = trueConnections = true
Note   By default, Windows SharePoint Services does not grant access to the Microsoft SharePoint object model. To grant access, you must raise the associated trust level by one of several methods. The next section discusses these methods.

Tuesday, November 8, 2011

workflow: Copy a document from one SharePoint document library to another


Creating the custom SharePoint workflow

  1. In SharePoint, create 2 document libraries: One to copy documents from and another one to store the copied documents in. Note: These document libraries do not have to be located on the same site.
  2. In Visual Studio, create a SharePoint Sequential Workflow. If you are unsure as to which steps you have to take to create a SharePoint workflow, refer to the tutorials in the Visual Studio workflows for SharePoint mini course.
  3. Add a Code activity to the workflow.
    SharePoint Sequential Workflow with a code activity to copy a document to a library.
    Figure 1. SharePoint Sequential Workflow with a code activity to copy a document to a library.
  4. Write the following code in the ExecuteCode event handler of the Code activity:
    // Get the item the workflow is running on
    SPListItem item = workflowProperties.Item;


    // Set the name of the document library and site
    // where to copy the document to
    string siteUrl = "http://<ServerName>/<SiteName>/";
    string libName = "DocLibForCopies";


    // Open the site
    using (SPSite site = new SPSite(siteUrl))
    {
      using (SPWeb web = site.OpenWeb())
      {
        if (item.File != null)
        {
          // Copy the document to the library
          SPFolder library = web.Folders[libName];
          library.Files.Add(
            item.Name, item.File.OpenBinary());
          library.Update();
        }
      }
    }

    where ServerName is the name of your SharePoint server, SiteName the name of the site on which the second document library is located, and DocLibForCopes the name of the second document library to which documents will be copied.
  5. Attach the workflow to the document library that contains the documents you want to copy, and select the Allow this workflow to be manually started by an authenticated user with Edit Item Permissions check box when attaching the workflow to the document library.

Testing the workflow

Now whenever you manually start the workflow on a document in the first document library, that document will be copied to the second document library and the workflow will end.
To manually start the workflow:
  1. Hover over a document in the first document library until a drop-down list box appears, click on the down arrow, and select Workflows from the context menu that appears.


    Accessing the workflows that can run on a document in a SharePoint document library.

    Figure 2. Accessing the workflows that can run on a document in a SharePoint document library.
  2. On the Workflows page under Start a New Workflow, click the workflow you want to start.
    Manually starting a SharePoint workflow.

Difference between SharePoint workflows and SharePoint event handlers


The main differences between SharePoint event handlers and SharePoint workflows are:
Initiation
SharePoint event handlers are automatically initiated, while SharePoint workflows can be initiated either automatically or manually.
Response
A SharePoint event handler always responds to an event that has taken or is taking place on an item, while a SharePoint workflow does not necessarily have to react to an event that is taking place. While it can react to an item being created or changed, you can also manually start a workflow after an item has been created.
User Interaction
SharePoint event handlers have no user interface, so users cannot interact with event handlers. On the other hand, you can create either ASP.NET or InfoPath forms to provide user interactivity with SharePoint workflows. And you can add even more interactivity by using SharePoint Tasks lists along with the workflow.
Duration
SharePoint event handlers run for a short period of time (generally seconds), while SharePoint workflows may run for a much longer time period (days, months, or even years).
Robustness
Since SharePoint workflows are hydrated and dehydrated, they can “survive” server reboots, while SharePoint event handlers cannot.

enable tree view navigation in sharepoint


ntroduction

A document management system should allow for easy retrieval of documents. Part of being able to easily retrieve documents is being able to easily navigate documents.

The flat folder structure of document libraries

In SharePoint, documents are stored in documents libraries, and documents libraries can have many levels of folders and subfolders. But a SharePoint document library can only display documents and folders on one level at a time (see Figure 1).
Folders in a SharePoint document library.

Figure 1. Folders on a single level in a SharePoint document library.

Enabling a hierarchical folder structure

You can enable tree view navigation in a SharePoint site to allow for easy browsing of documents in document libraries and other site content (see Figure 2).
Site Hierarchy on a SharePoint site.
Figure 2. The Site Hierarchy section in the left navigation bar after enabling tree view navigation.
To enable tree view navigation:
  1. Go to the SharePoint site for which you want to enable tree view navigation.
  2. On the Site Actions menu, choose Site Settings.
  3. On the Site Settings page under the Look and Feel category, click Tree view.
  4. On the Tree view page, select the Enable Tree View check box.Tree view page in WSS 3.

document management web parts


The Relevants Documents web part in SharePoint.
The Relevant Documents web part allows you to:
  • Display documents that were last modified by the current user
  • Display documents that were created by the current user
  • Display documents that are checked out to the current user
  • Display a link to the folder or list containing a particular document
If you are working in an environment with a lot of documents, the Relevant Documents web part can help you save time when locating and using documents.

Adding the Relevant Documents web part to a SharePoint web page

To add the Relevant Documents web part to a SharePoint web page:
  1. Go to the SharePoint site and web page to which you want to add the web part.
  2. On the Site Actions menu, click Edit Page.
  3. On the web part zone where you want to add the Relevant Documents web part, click Add a Web Part.
  4. On the Add Web Parts web page dialog, select Relevant Documents, and click Add.
    The Add Web Parts web page dialog in SharePoint with the Relevant Documents web part selected.
    The Relevant Documents web part in the left web part zone on a SharePoint web page.
  5. On the Relevant Documents web part, click edit, and then Modify Shared Web Part (when adding the web part to the Shared version of a page).
  6. In the Relevant Documents web part properties on the right side of the screen, click Data to expand the Data section.
  7. In the Data section, select the features you wish the Relevant Documents web part to display, and click OK.
    The Data features section of the Relevant Documents web part in SharePoint.
  8. Click Exit Edit Mode when you’re done editing the SharePoint web page.

add a content type to a SharePoint document library


Content types allow you to store documents of different types in the same SharePoint document library. For example, you can use content types to define multiple document templates on a SharePoint document library.
Adding a content type to a document library in SharePoint is a 2-step process:
  1. Enable the management of content types on the document library.
  2. Add the content type to the document library.

Enabling management of content types on a document library

By default, content types are disabled on document libraries in SharePoint. So before you can add a content type to a document library, you must enable management of content types on that document library.
To enable management of content types on a SharePoint document library:
  1. In SharePoint, go to the document library on which you want to enable management of content types.
  2. On the Settings menu, click Document Library Settings.
  3. On the Customize document library page under General Settings, click Advanced settings.
  4. On the Document Library Advanced Settings page, select Yes under Allow management of content types?, and click OK.
Allow management of content types on a SharePoint document library
Figure 1. Allow management of content types on a SharePoint document library.

Adding a content type to a SharePoint document library

Once you’ve enabled the management of content types on a SharePoint document library, a Content Types section appears on the Customize document library page.
Content Types section on the Customize document library page
Figure 2. Content Types section on the Customize document library page.
Now you can click Add from existing site content types under the Content Types section on theCustomize document library page to add a content type to the SharePoint document library.

Get Full or Relative Url of web using Javascript Client Side


var context = new SP.ClientContext();
var relativeWebUrl = context.get_url();
Remember the get_url method will only return relative url of the site. As shown in the following table:
Site Collection UrlSite Urlcontext.get_url() response
http://site.comhttp://site.com/
http://mysite.comhttp://site.com/site1/site1
http://site.com/siteshttp://site.com/sites/site1/sites/site


function getFullWebUrl() {
    var context = new SP.ClientContext();
    var relativeWebUrl = context.get_url();
    var fullWebUrl = window.location.protocol + '//' + window.location.host + relativeWebUrl ;
    alert(fullWebUrl);
}

Featured Posts

Learn how to install Apache, MySQL and PHP on Ubuntu. Complete LAMP stack installation guide with one-shot commands, PHP testing and php-opcache troubleshooting

How to Install LAMP Stack on Ubuntu | Complete Guide UBUNTU • LINUX • SERVER • PHP ...