Friday 28 September 2007

MOSS - Targeting content to Sites not Audiences

Audience targeting is a great way to push information to individual users from a central source - but what about when you want to push information to particular sites? My example is a series of department sites. Sounds easy - content query web part (CQWP) filtered on a choice column on your list of announcements/documents/links etc to say which department the item is relevant to. Job done? well until you need to say that this item is for multiple departments...

Try changing the choice from dropdown to "checkbox/multiple". The text that appears in a list view is great "choice1;choice2;choice3" etc. Great! lets filter using "contains" in the CQWP. Not really - while you see the value in the interface as a string, th CQWP won't when filtering - so you end up with no results? The answer? Content Types and Workflow. For the rest of this article I'm working with a document library with a "Relevant Department" column

Create a new Content Type

(mine is at the top portal level for reuse). I called mine "My Choices Content Type", inherited it from "Document" and added it to "Test Content Types" to keep it seperate. I added 2 new site columns

  • MyChoices - a checkbox based choice column

  • MyChoices_Text - a single line text column

Go to your document library/annoucements list/ etc and change it to allow content types, add your new content type and remove any others from the list. Don't upload any documents or create any items yet.

Create a Workflow in SharePoint Designer

Open up the site containing your document library in SP Designer. From the file menu select New > Workflow, configure yours similar to mine below:






This workflow will copy the (non-text) multiple choices into a text column, thus exposing it as text to the CQWP.

Ammend CQWP to Filter based on our content type

Now that we have this property create a CQWP on your "department" site. Configure it as below to point at our list, our content type and then filter it based on the Site Column "RelevantDepartment_Text" and use the filter operator "Contains". Enter a string matching one of your choice values. OK these choices.



Congratulations, you should now have a list of documents that can be relevant to more than one department, pushed through to the site of your choosing.