Welcome to MSDN Blogs Sign in | Join | Help

How To Automatically Changing Permissions in a Doc Lib

Or, how do you get Item-Level Permissions settings for a document library?

This frequently comes up for me with InfoPath forms libraries. For example, you are automating an HR performance review process with SharePoint workflow and InfoPath forms. Reviewers will go to a SharePoint form library, click New and fill out a performance review form for a coworker. User must be able to only see their forms. And managers must be able to see the forms for their direct reports.

If you look at the Advanced Settings for a SharePoint list (e.g. a Task list or custom list), you will see these options:

ItemLevelPermissions

This looks like exactly what you want. However, if you look at the Advanced Settings for a document library, there are no such settings.

Fortunately, there is a codeplex solution: Change item’s permissions on creation. I really like this implementation because it is an Information Management policy. I started looking into implementation a solution myself and the tricky part started to be: how is a user going to specify the document library. Using an Information Management policy is perfect because it uses an existing mechanism for making library-wide settings.

Posted by Ben Hickman | 0 Comments
Filed under:

SharePoint Designer Workflows – what user identity?

When a SharePoint Designer (SPD) workflow runs, it runs in the context of the workflow initiator. This is important to know if the initiator may not have permissions to everything that the workflow uses.

An example:

  • A broad set of users have permissions to load documents into a library named Active.
  • A small set of users process the documents and change a Status column to Verified when done (it’s preset to New in the previous step).
  • You want a workflow to move the documents from the Active library to the Archive library when Status = Verified.
  • The users that load documents into Active do not have any permissions to Archive.

You have two choices for creating this workflow in SPD:

  1. Automatically start this workflow when a new item is created, with these steps:

    WF-Wait
  2. Automatically start this workflow whenever an item is changed, with these steps:

    WF-Condition

Both workflows will run under the context of the initiator. In this case, the initiators will be different and have different permissions.

In the first case, the initiator is the user that loaded the document and that user does not have permissions to the Archive library. Meaning this workflow will always fail because it will not have permissions to perform the copy step.

In the second case, the initiator is the user that changes the status to verified. That will be a user with permissions to the Archive library. That workflow will succeed.

So consider permissions when choosing between various SPD workflow options.

Secondary Workflow Example in SharePoint Designer

I recently built a prototype to show how SharePoint and SharePoint Designer workflows can be used to automate an HR performance review process. I had to use a secondary workflow as described in SharePoint Designer: Create a secondary workflow, but had to come up with a different solution for how to set due dates. Following is an explanation of why I needed the secondary workflow for this example and how I got the due dates to work.

The basic requirements are:

  • A manager wants to start a performance review process for an employee.
  • Each employee has some list of people to review them.
  • The review consists of filling out an InfoPath form.

I created the following in SharePoint:

List/Library Purpose
Performance Reviews An InfoPath form library that will contain completed review forms. This form library contains the performance review form as an InfoPath form template.
Reviewer Tasks A task list to store tasks assigned to reviewers.
Reviewers A custom list of reviewers for each person being reviewed. This list has two columns: Employee and Reviewers. The latter is a multiple select Person column.

Now the workflows. A workflow needs a list or library item to be started. Since the Performance Reviews form library only contains completed review forms, it is not a candidate for the workflow. Instead, my Reviewers list contains the mapping between employees and reviewers and is where the workflow will start. Following the diagramming used in the referenced article, here are my lists and workflows:

WorkflowSecondary

  1. A manager manually starts the Performance Review workflow for a particular employee. This workflow uses an initiation variable to get the Due Date for the performance review from the manager.
  2. The Performance Review workflow creates tasks for each of the reviewers.
  3. The Set Task Details workflow runs automatically on each of the new tasks to set their details and send email notifications to the reviewers.

The Performance Review workflow uses the Assign a To-Do Item action to assign tasks to the reviewers.The Set Task Details workflow is required because the Assign a To-Do Item action has the following limitations in this case:

  1. It only supports a static title and description. I need both the title and the description to include lookup fields so the assigned tasks are most meaningful to the reviewers (e.g. “Please complete a performance review for Ben Hickman”).
  2. It doesn’t support a due date. I want to set a due date on the tasks.
  3. It does not send email notifications that a task has been assigned. I could setup Alerts on the task list, but I want control over the format and details of the email notifications.

Now the trick is: how does the Secondary Workflow find the Employee name and the Due Date? As described in the article referenced above, the Secondary Workflow can use the Current Item – Workflow Item ID to reference the Reviewers item id that caused the task to be created. I can then use that Workflow Item ID to lookup the associated item in the Reviewers list and lookup the Employee name, like this:

WorkflowItemID

Now, how about the Due Date? Since I gathered that as an initiation variable in the Primary Workflow, it’s not immediately available to the Secondary Workflow. So, I better make it available. I do that by having the Primary Workflow store it in the Current Due Date column in the Reviewers list. Then, the Secondary workflow can look it up just like Employee like this:

WorkflowDueDate Now I have tasks with rich titles and descriptions, specific due dates, and detailed notification emails.

Content Query Web Part example

I recently got deeper into using the Content Query Web Part (CQWP) than I had in a while and learned a few things. The first thing you should do to learn about the CQWP is read this article from Heather Solomon’s blog: Customizing the Content Query Web Part and Custom Item Styles. I follow the process she describes when using the CQWP.

The Solution

We built a Site Collection that included a top-level site with highlighted and summary content and a large number of sub-sites that included wikis and blogs. Each sub-site had a different group of content contributors. The owner of the top-level site wants to be able to highlight and promote sub-site content to the top landing page. I built this with a custom list and a CQWP.

The custom list contains enough columns to reference content by URL and add summary info that can be display at the top-level landing page:

Columns

Then I placed a CQWP on the landing page to display that custom list with a specific layout:

CQWP

CQWP Details

Here is what I learned in the process. All of this applies to the XSL you write in ItemStyle.xsl.

Debugging

When working with custom fields in the XSL, it was helpful to use this to display all the column names and their values:

<xsl:for-each select="@*">
    F:<xsl:value-of select="name()"/>--<xsl:value-of select="."/><br/>
</xsl:for-each>

URL Columns

Using the script above on a URL column, you’ll notice that URL values are stored as “http://msdn.microsoft.com, http://msdn.microsoft.com”. This is to support this style of rendering:

<a href="{substring-before(@URLColumn, ', ')}">
         <xsl:value-of select="substring-after(@URLColumn, ', ')"/>
</a>

Therefore, if you just want the URL, use substring-before(@URLColumn, ‘, ‘).

Pictures and Rich Text

Both Picture and Rich Text column types are stored with embedded HTML markup. By default, when you use XSL to render these column values, the HTML is escaped and the viewer sees the actual markup rather than just the formatted content. To render these column values, use the disable-output-escaping attribute:

<div class="image-area-left">
    <xsl:value-of select="@Icon" disable-output-escaping="yes"/>
</div>

Rating Web Part

Finally, I used the Rating web part from Codeplex to allow viewers to rate the content. Now I needed to display the rating value or a link to rate the item in the CQWP. Here’s how I did that:

<xsl:variable name="ListGuid">
    <xsl:value-of select="@ListId"/>
</xsl:variable>


<xsl:variable name="ItemId">
    <xsl:value-of select="@ID"/>
</xsl:variable>

 <div>    
    <xsl:choose>
         <xsl:when test="contains($Rating, '(5)')">
              <img src="/_layouts/images/sptoolbasket/rating_5.gif" alt="{$Rating}"/>
         </xsl:when>
         <xsl:when test="contains($Rating, '(4)')">
              <img src="/_layouts/images/sptoolbasket/rating_4.gif" alt="{$Rating}"/>
         </xsl:when>
         <xsl:when test="contains($Rating, '(3)')">
              <img src="/_layouts/images/sptoolbasket/rating_3.gif" alt="{$Rating}"/>
         </xsl:when>
         <xsl:when test="contains($Rating, '(2)')">
              <img src="/_layouts/images/sptoolbasket/rating_2.gif" alt="{$Rating}"/>
         </xsl:when>
         <xsl:when test="contains($Rating, '(1)')">
              <img src="/_layouts/images/sptoolbasket/rating_1.gif" alt="{$Rating}"/>
         </xsl:when>
         <xsl:otherwise>
              <a href="
/_layouts/sptoolbasket/ItemRating.aspx?Id={$ItemId}&amp;List={$ListGuid}">Rate</a>
         </xsl:otherwise>
    </xsl:choose>
</div>

The CQWP is powerful both for formatting the display as well as query content. In this particular case, I used the former more than the latter since I was only querying a single list.

Posted by Ben Hickman | 1 Comments
Filed under:

Accessing columns in the User Information List

I was recently asked how to programmatically retrieve custom fields from the User Information List via a Web service.

It turns out that the GetUserInfo web method does not return any custom fields that you might add to the User Information List (aka People & Groups).

Instead, just treat this as a regular SharePoint list and you can access the columns via the GetListItems web method from Lists.asmx.

static void Main(string[] args)
{
    ListsService.Lists svcLists = new ListsService.Lists();
    svcLists.Credentials = CredentialCache.DefaultCredentials;
    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<Document><Query /><ViewFields /><QueryOptions /></Document>");
    XmlNode listQuery = doc.SelectSingleNode("//Query");
    XmlNode listViewFields = doc.SelectSingleNode("//ViewFields");
    XmlNode listQueryOptions = doc.SelectSingleNode("//QueryOptions");
    Guid g = GetWebID("
http://moss.litwareinc.com");
    System.Xml.XmlNode items = svcLists.GetListItems("User Information List",
        string.Empty, listQuery, listViewFields, string.Empty, listQueryOptions,
                g.ToString());
    Console.WriteLine(items.OuterXml);
}

private static Guid GetWebID(string webPath)
{
    SiteDataService.SiteData svcSiteData = new SiteDataService.SiteData();
    svcSiteData.UseDefaultCredentials = true;
    SiteDataService._sWebMetadata webMetaData;
    SiteDataService._sWebWithTime[] arrWebWithTime;
    SiteDataService._sListWithTime[] arrListWithTime;
    SiteDataService._sFPUrl[] arrUrls;
    string roles;
    string[] roleUsers;
    string[] roleGroups;
    svcSiteData.Url = webPath + "/_vti_bin/sitedata.asmx";
    uint i = svcSiteData.GetWeb(out webMetaData, out arrWebWithTime,
        out arrListWithTime, out arrUrls, out roles, out roleUsers,
        out roleGroups);
    Guid g = new Guid(webMetaData.WebID);
    return g;
}

Now if I add a column to the User Information List, that new column appears in the items list.

One other option is RSS. The User Information List has an RSS feed and you can configure it to include your custom columns. Of course, this only shows new records and is not useful for export or update.

Posted by Ben Hickman | 1 Comments
Filed under:

One Part of Microsoft.com now running on SharePoint

Yesterday http://www.microsoft.com/sharepoint converted over to SharePoint and Silverlight. It’s nice to have a microsoft.com example to add to the list of public facing sites running SharePoint.

There’s an upcoming SharePoint team blog posting on how it was done.

Posted by Ben Hickman | 0 Comments
Filed under:

SharePoint Server 2010 announced

I will need to switch from saying SharePoint 14 to SharePoint 2010 now. Details of the announcement are on the SharePoint Team Blog.

Posted by Ben Hickman | 0 Comments

New Capabilities for SharePoint

Today we announced the ESP for SharePoint product that provides high end search capabilities within SharePoint. We also detailed the road map for the next version of SharePoint and how these high end search capabilities will be folded into the platform. Details are in the blog posting:

Microsoft Unveils New Enterprise Search Road Map

A few weeks ago, we also announced that our BI products, Performance Point, are also being rolled into SharePoint:

Microsoft Business Intelligence strategy update and SharePoint

This is huge news for SharePoint and our customers that have already made an investment in this platform. Powerful new capabilities have been added to SharePoint to democratize BI and enable powerful and customizable search experiences.

Posted by Ben Hickman | 1 Comments

New SharePoint for Developers Ramp Up Training

As part of the MSDN Ramp Up training program, there is now a track for SharePoint Developers:

SharePoint for Developers Track

This track consists of 5 levels of training content:

  1. Web Parts
  2. Data Lists
  3. Event Handlers
  4. Workflow
  5. Silverlight Web Parts

Each level contains a collection of articles, slide casts, code casts, and virtual labs. This is an awesome new resource to get up to speed with SharePoint development quickly.

Did I mention it's free of charge?

Posted by Ben Hickman | 0 Comments
Filed under:

SharePoint Guidance from Patterns & Practices

The Patterns & Practices group at Microsoft has just released SharePoint Guidance documents. This is Microsoft's recommendations for how to design, develop, deploy and operate architecturally sound applications on the Microsoft platform.

This guidance documentation set is targeted at helping you build intranet applications with SharePoint. It's not just a whitepaper. It includes a reference implementation of a training management application built on SharePoint. Meaning you get a better understand of not only the technical details of how to implement the solution, but also the architectural decisions about patterns, factoring, and packaging. You'll also see the design tradeoffs that you will likely encounter when creating intranet applications with MOSS.

Highly recommended:

New Home for Ben Hickman's Blog

If you got a slew of RSS feed updates today it's because I moved my blog over to MSDN.

 

I've moved all the old posts over here and this is the new home.

Posted by Ben Hickman | 0 Comments

Office 14 for the Web

Yesterday at the PDC2008 conference, we announced Office 14 for the Web. There is a great Channel 9 video with a demo:

First Look: Office 14 for Web

There are also some good screen shots on Joel Oleson's blog:

Office 14 Web applications in SharePoint

Office 14 will support rich desktop client, Web browser, and mobile versions of Word, PowerPoint, Excel, and OneNote. The browser versions will be cross platform and cross browser. These versions will also support simultaneous editors of a single document across the three client choices.

The Web browser versions will be available through OfficeLive in an ad supported model, as an online subscription or via SharePoint 14.

Posted by Ben Hickman | 0 Comments

Good SharePoint Designer Book

It's good to see some SharePoint Designer books starting to appear. Even though I use Visual Studio .NET alot, I still use SharePoint Designer for master page development, the Data View Web Part, and simple workflows.

I picked up this book and it is especially good at covering the Data View Web Part:

Microsoft Office SharePoint Designer 2007 Step by Step

by Penelope Coventry

Content Rating for MOSS Released on CodePlex

I just found out that a Content Rating solution for MOSS 2007 was released to CodePlex earlier this month:

Content Rating for MOSS 2007  ContentRating

This is very cool. Now you can build sites that allow users to rate and comment on SharePoint content. For example, create an FAQ site using the Wiki template and allow users to rate the FAQs.

It's also used the in the Podcasting Kit for SharePoint so users can rate uploaded Podcasts.

The solution includes a database schema, web parts, and fields.

Posted by Ben Hickman | 0 Comments
Filed under:

SharePoint Licensing Info

I gave an overview presentation last week on SharePoint for Internet and extranet sites. During the Q/A, I got some questions about licensing of WSS and MOSS for these scenarios. There are a number of different parameters that affect licensing and here is a good FAQ on the topic:

MOSS 2007 FAQs: Licensing
http://office.microsoft.com/en-us/sharepointserver/HA101655351033.aspx#2

Posted by Ben Hickman | 0 Comments
Filed under:
More Posts Next page »
 
Page view tracker