Archive: Manage Content Owners with the Content Query Web Part (CQWP)

This article was originally written in February 2012.  It is being reposted here as an archive.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The CQWP is my absolute favorite out of the box web part.  There are so many things that you can do with it.  There are lots of great blogs out there describing how you can present information to your end user with the CQWP, but did you know that you can also use it to determine how your content owners are using their sites?  Are they entering the type of data that you expected them to when you created your form?  Do content owners understand the importance of certain processes, such as clicking on “Publish” to make a page visible to readers?  Did your users really “get” the training that you gave them?

The current project I am working on is getting ready for a huge launch.  It is a publishing site with minor and major versioning turned on for Pages and Document Libraries.  It is one parent site with 100+ sub-sites, each containing hundreds of pages and documents.  We created a custom web part for content owners to link to other pages in the site collection.  This web part is really cool in that it shows the name of the page or document, the date it was reviewed, user ratings, a brief summary of the content and a link to the page or document.  We want to give the reader some useful information about the link before they decide to click on it.

With so much content in the site, we are relying on content owners to enter information about the content in a field that will be displayed in FAST Search and will also be displayed in the custom web part to link to related content.  The web part respects security, meaning a user must have access to the content in order to view the description in the web part.  With a big launch coming up, I wanted to do a content check to see how we are doing.  I don’t have time to go randomly clicking around on all these sites, so I created a couple of CQWP’s in order to see how the site is being populated.  They also ended up helping our development team complete a final review of our work.

If you’re new the CQWP, it is a web part that you can add to a web part page that can ask all of the sites in your site collection to give you a certain kind of information.

For example, if this wall of candy dispensers is your site collection, with each dispenser being one site:

CQWP1

 

Then this is the CQWP:

CQWP2

It has done all the work for you and grabbed multiple types of candies for you to consume quickly.  Yes, I could go to each tube and grab a little from each…but that just takes way too long and I want my candy NOW J.  With the CQWP you can filter your candy to get the specific ones that you need (if you don’t want the brown ones you don’t have to have them).

The CQWP is out of the box when the publishing feature is turned on, and it’s pretty quick to configure, especially with practice.  Here are some examples of how I was able to spend a few minutes looking at how the users are using the site and avoid deployment issues.  All of these queries were done in a browser, with no .xslt edits.  Each took no more than 15 minutes to configure, check, adjust, check, etc. to show exactly what I want on the page.

  • Check on published versions

o   Created 2 queries, one for all “Pages” libraries and one for all “Document Libraries” across the site collection, filtered by version is less than 1.0 and displays the last person that modified the content.

o   Problem Avoided:  Users not being able to access pages with page not found error, access denied errors and empty custom web parts

  • In order for a site reader to see a page or document the user must publish a page, or check in a major version.
  • This makes the version 1.0 (or 2.0, 3.0, etc. as you publish major versions…drafts always have a decimal).  A document that does not have a published version will have a version less than 1.0, which is why I filtered for by version.
  • There were over 400 pages and documents that did not have a published version just two weeks before go live

 

  • View user-completed fields

o   Created 2 queries, one for all “Pages” libraries and one for all “Document Libraries” across the site collection, which display the page title and our custom summary field and the content owner.

o   Problem Avoided:  Poor search results, poor cross-site link descriptions

  • There were over 300 items with “-“, an incomplete description or a duplicate description in the summary field that is displayed in our custom web part and search results.
  • Validation or unique values were not viable options in this case.

 

  • Discover users storing documents in wrong locations

o   Created one query for all sites, grouped by Page Layout, which showed users were putting Word and .pdf documents in their Pages Libraries (since they had no page layout)

o   Problem avoided:  Documents stored in wrong locations would not display correctly to the end user

  • We created Pages Libraries for publishing pages and Document Libraries for all stand-alone documents.  All documents are presented with a custom page that displays certain properties, taxonomy, user comments and ratings.

The overall outcome of these CQWP’s is that we were able to target the users that needed additional training tips in order to make sure their content is not only visible, but findable for end users on launch day.

Additionally, CQWP’s helped our development team to create a better product:

  • Monitor page layout usage and react

o   This was a unique project where editors were adding content while we were developing the site.  By creating CQWP’s that grouped all Pages by Page Layout we were able to:

  • View how users are actually using the page layouts we designed with content and adjust as needed
  • Allow our front end developer to make changes to design based on usage
  • Allow our back-end developers easy access to test the pages and how they worked with our custom controls and actual content

If you’re not familiar with the content query web part, I strongly recommend spending some time getting to know this very powerful web part.  It has been the fastest way for me to get feedback on what’s going on in our sites, so that we can address training issues, user adoption and design before they become a problem.

 

 

Archive: Assign a Custom Content Type to Task Process in a SharePoint Designer 2010 workflow

This article was originally written in February 2012.  It is being reposted here as an archive.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

SharePoint Designer 2010 has some awesome new features!  Two of my favorites are (1) the ability to copy and modify an out of the box workflow and (2) the custom task processes.

What I don’t love is the way SharePoint assigns names with spacing to these tasks that have “_X0028_” and “_X0029_copy” in it.  It can cause problems with importing the workflow into Visual Studio, referring to the content type in custom web parts, and as an architect, I just don’t like the way it looks too messy.  Plus, if I want to make changes to the task list or roll the task up in a web part, I don’t want to have to guess which task goes with which workflow.

Here is an example of what SPD does when it adds a custom task action to a workflow or when you copy out of the box (OOB) workflow:

SharePoint Designer 2010 Workflow - Custom Content Types

SharePoint Designer 2010 Workflow – Custom Content Types

And this is what I want it to look like:

SharePoint Designer 2010 Workflow - Custom Content Type Desired Name

SharePoint Designer 2010 Workflow – Custom Content Type Desired Name

And it’s not just aesthetics; I have certain fields that I want to be able to store in the task.  I know that I can assign them in the workflow task process, but I don’t want the end user to see them so I want them hidden.

Here are the steps:

  1. Create your custom content type at your parent site (or content hub).
  • Important note:  If you are going to be exporting your workflows to other environment (i.e. local to production) and you do not use a content type hub, I STRONGLY recommend creating these content types and any site columns associated with the workflow with code.  This will ensure that your GUID’s (custom ID’s) are the same across all environments.

–   I worked with a developer to create my site columns and content types for me since we are moving workflows across environments

–   If you do not have access to a developer, then you will need to replicate these steps in each environment to make sure the ID’s are correct for each.

  1. Optional Step: If you want the “Claim Task”, Custom Outcomes functionality, and the ability to Reassign or Request Changes that comes with the out of the box workflow tasks for Enterprise SharePoint, you will need to change the display and edit forms.  If not, you can skip this step.

Example of InfoPath display form vs .aspx display form

SharePoint Designer 2010 Workflow - InfoPath Form vs .aspx form

SharePoint Designer 2010 Workflow – InfoPath Form vs .aspx form

  • If you create the content type in Code, make sure the display and edit form properties include “_layouts/WrkTaskIP.aspx”
  • If you create the content type by hand (or did not assign a display/edit form specification in the code), open the content type in Designer and change the display and edit form to “_layouts/WrkTaskIP.aspx” under “Forms” on the right side of the screen.
SharePoint Designer 2010 Workflow - Forms

SharePoint Designer 2010 Workflow – Forms

  1. Create your workflow
  • Either Copy and Modify an out of the box workflow
  • OR Create a new workflow and add a custom task process – Start Approval Process, Start Custom Task Process or Start Feedback Process

–   (I have not tested this with the other task actions)

SharePoint Designer 2010 Workflow - Task Processes

SharePoint Designer 2010 Workflow – Task Processes

 

  1. Save the workflow, but do not publish it.
  • NOTE: If you have published it and have the odd-named content type, just delete that task form.  We will generate a new task form at the end.

–   This odd-named content type will exist in your Content types library until you delete it from there

  1. Open the custom content type you created in Designer and Copy the ID
SharePoint Designer 2010 Workflow - Task Content Type ID

SharePoint Designer 2010 Workflow – Task Content Type ID

 

  1. Go to All Files, Workflows, <WorkflowName> folder
  • Note: If the “All Files” folder looks empty, click on another folder, such as subsites, and select “All Files” again.
SharePoint Designer 2010 Workflow - Workflow Files

SharePoint Designer 2010 Workflow – Workflow Files

 

  1. Open the file that ends in  “.wfconfig.xml” and replace the following items:
  • Line 2: TaskContentType=”<ID>” with your custom content type
  • Line 4: ContentType Name=”<Name>” with your custom content type name
  • Line 4: ContentTypeID  = “<ID>” with your content type ID you copied from previous step
  • Line 4: WorkflowForm= “Workflows/<workflowname>/<contenttypename.xsn>” with your content type name (just the name of the form, leave the folder name as is)
SharePoint Designer 2010 Workflow - Replace Content Type Code

SharePoint Designer 2010 Workflow – Replace Content Type Code

Here is what it should look like (my content type is “IntakeReviewTask”)

SharePoint Designer 2010 Workflow - Replace Content Type Code

SharePoint Designer 2010 Workflow – Replace Content Type Code Result

*Line 2 not pictured

  1. Save the the xml file and go back to your workflow folder

 

  1. Hover over the file that ends in “.xoml” file and select “Open with”  -> “2. SharePoint Designer (Open as XML)”.

    SharePoint Designer 2010 Workflow - Open as XML

    SharePoint Designer 2010 Workflow – Open as XML

 

  1. Click (Ctrl+F) for Find and enter “ContentType” in the “Find what” box
SharePoint Designer 2010 Workflow - Find and Replace

SharePoint Designer 2010 Workflow – Find and Replace

  1. Replace the ContentTypeID=”ID” with your custom content ID

 

  1. CLOSE SharePoint Designer and re-open it.
  • Refreshing has not worked for me.
  1. Open Designer, open your workflow by clicking on “Workflows” and Save your file.   Click “No” if you receive any messages to replace your file.
SharePoint Designer 2010 Workflow - Do Not Replace

SharePoint Designer 2010 Workflow – Do Not Replace

 

  1. Publish your workflow.  The right side of the picture below shows my workflow after completing this process.
SharePoint Designer 2010 Workflow - Replaced Content Type

SharePoint Designer 2010 Workflow – Replaced Content Type

And Voila, no more messy names and you can use your custom content type for whatever you may need, displayed in a CQWP, for example.