Posted: October 19th, 2009    By: Devin Walker   

Final Look of our Announcement
The frontpage of any corporate Intranet should have announcements to provide site users with up to date information about the on goings of the company. SharePoint provides a number of options to make this possible. The following article will provide you with information about how to use the Data View Web Part to display an Announcements list. This method allows for greater customization than some of the methods and is rather easy to implement.

Let’s begin with the scenario: In some companies announcements are typically mailed through a distribution list to all employees. The SharePoint announcement list we have setup currently is receiving e-mail via the distribution list and stores the information in the appropriate columns. The best way to display this info is using the Data View. For more setup information read below.

List Setup Tips:

To create an Announcements list View All Site Content > Create > Announcement (under Communications)

SharePoint Announcement List

To enable your list to receive e-mail – Enter the list > Settings > List Settings > Incoming E-mail Settings (Under Communications)

SharePoint Incoming e-mail settings

The following assumes that you already have this announcement list setup.

1. Now that the announcement list is setup and hopefully already has at least one entry in it (if it doesn’t create a test announcement) we are ready to open the page we want the data view on it SharePoint Designer 2007. Right click on the page, check it out and detach from page layout.

SharePoint Designer Open File

And

Detach a page from the page layout using SharePoint designer

2. Select the Web Part Zone you wish to display the announcements by clicking on the title. Insert the data view by selecting Data View > Insert Data View on the top menu. This will open the Data Source Library task pane and you will see a list of data sources on the current site.

Insert Data View

3. Select the Announcements list drop down in the data source library and click. If you do not see the list it is possible it could be on another site collection. You will have to connect to this library via the Connect to another library… link in the Data Source Library task pane.

Show Data

4. We can now see all the rows in the Current Data Source that we just selected. For this case we will select the following rows to display – Title, Created, E-Mail Sender and Body. Select these rows by holding the Ctrl key and clicking them with your mouse. Once you have all the rows you would like to display selected click Insert Selected Fields as… > Single Item View

Single Item View

5. You will notice that the data view is now displaying the fields in the order of the rows we selected in two columns. My personal preference is the first column displaying the name of the row has got to go… let’s delete this by right-clicking within any of the rows within the column we want to delete and selecting Delete > Delete Columns

Delete the Columns

6. Now the ordering may need to be changed depending if you want the body on the bottom or e-mail sender on the top, etc. This is done by selecting the entire WebPartPages: DataFromWebPart > Selecting the menu to the right > Edit Columns

Now the ordering may need to be changed

You can now Move Up or Move Down the Displayed Columns

You can now Move Up or Move Down the Displayed Columns

7. Now you probably will want the Title of your announcement to be a hyperlink that directs to the list entry page. By default your title will be text format and look rather boring. To set this as a hyperlink to the menu item we will need to select the column and use the menu to the right (using the small arrow) and change the Format to Hyperlink

Change the Format to Hyperlink

Note: This will pop a warning message saying only in a trusted environment… Ok this to open the Edit Hyperlink window.

pop a warning message saying only in a trusted environment

8. Now this is where it gets semi-tricky. The way I found the correct URL was by using the Content Query Web Part. Explaining further, before using data views to display announcements I was using custom CQWPs to display the data. This was alright for awhile, but I kept running into problems and realized that data views are the best way to display the information. Plus they are just easier to work with.

To get the correct hyperlink for the {@Title} value follow these steps:

a. Insert a Content Query Web Part to any zone on the page

b. Modify the web part to query items from the announcements list we created in the introduction of this article and click OK.

Modify the web part to query items

c. Preview your page in Internet Explorer and right click on the announcements titles to get the URL. Copy this hyperlink to your clipboard. The whole hyperlink will look something like this:

http://mySharePointServer.com/_layouts/CopyUtil.aspx?Use=id&Action=dispform&ItemId=14&ListId=10B06D13-1F0D-4E86-8183-9CD43DFEC217&WebId=D11E6E1F-3155-433D-B3A0-4CD31FD5B038&SiteId=01574ebc-b0f8-43e0-9b8c-95aa6ccsaa30

Change the link to read:

http://mySharePointServer.com/_layouts/CopyUtil.aspx?Use=id&Action=dispform&ItemId={@ID}&ListId=DA4660F2-7F9A-4751-88F5-A7C26517F54C&WebId=E98A4391-677F-40C5-85C0-58A2AB4709B6&SiteId=02354ebc-b0f8-47e0-9b8c-95aa2cdeaa30

Important: Changing the Blue text above to ItemID={@ID} directs to the appropriate list item id; you don’t want all the links to go to that one specific announcement ID.

Tip: To find out the ListId you can select Data source properties… of the Current Data Source in the Data Source Details task pane.

Note: Make sure the Hyperlink’s title value remains {@Title} (SharePoint Designer will automatically change this field when the hyperlink reference changes).

9. Style the announcement title using the Conditional Formatting task pane. Select the Title column, this will enable the Create dropdown in the Conditional Formatting task pane. Click Create > Apply Formatting

Click Create and Apply Formatting

Now in the Condition Criteria add a new clause that states: Title Contains ‘ ‘ Now apply all the formatting you wish in the Modify Style window and click OK.

Note: the ‘ ‘ is simply a space meaning it can contain anything, the format is always applied.

Tip: You can create additional clauses for formatting keywords or highlighting key points, simply specify the word in the contains space… get it?

You can create additional clauses

Hint: You can also apply formatting by using the style options in SharePoint Designer

Tool options

10. Additional formatting: If you want to limit the amount of text displayed in the body of the announcement this is possible. Just double click on the body column and add the following formula substring(@Body,1,500) and manipulate the numbers to display the amount of text you wish.

11. Finish all your adjustments, save, reattach to page layout, check in and publish a major version so all audiences will see the new data view.

Final Look of our Announcement:

Final Look of our Announcement

If you have any problems please comment.

Related posts:

  1. SharePoint Browser Error Solution: Datasheet View Error Problem description: If a site has a document library using the Datasheet view a user will receive the following error when trying to navigate to the site. “The list is displayed in Standard view. It cannot be displayed in Datasheet view for one or more of the following reasons: A datasheet component compatible with Windows [...]...
  2. Link Two Lists and Display the Data Using the SharePoint Data View Do you have two lists that you would like to display their data in one convenient location? Well, the SharePoint Data View should work perfectly for this type of use. Follow along with the article to understand more about using the Data View to connect two list and display information of your choosing. To begin, [...]...
  3. Custom SharePoint List Icons Recently I was asked by my manager to create a dashboard for executive members to quickly see the progress of active projects. She explained to me that she wanted a “priority level” indicator similar to that of the KPI in a basic table structure. The color of the indicator would change depending on the status [...]...
  4. Import Outlook Calendar to SharePoint SharePoint makes it very easy to export Calendars from SharePoint to Outlook.  But what if you have an Outlook calendar that you want on SharePoint?  This becomes more difficult and you could quickly find yourself lost on how to complete this task.  Don’t worry though, it’s not that hard.  The following article will explain a [...]...
  5. How to remove the “title” column from a SharePoint list Have you asked yourself the question: How do I remove the ‘title column’ from a Sharepoint list?  It can be annoying trying to figure out how to remove this column from default lists.  Often, site admins want their audiences to click on “New Item” in a Sharepoint list and not have to fill out the [...]...
  • Alan McKenzie

    I found it impossible to retrieve the ListID using Content Query Web Part while trying to work this magic with a SharePoint Calendar. So I had a dig around and found another way to grab the ListID of a SharePoint list, regardless of its type.

    While looking at the List’s parent site in your browser simply, go Site Actions > View All Site Content. Then click on the List (Calendar, Announcements, whatever) to open it. Then choose Settings > List Settings.

    Now look at the URL in the browser’s address field. It’ll look like this:

    http://domain/_layouts/listedit.aspx?List=%7B5CA1C49D%2D6A41%2D4C50%2DAFE1%2D097A264B0707%7D

    and there’s the ListID right there. All you have to do is edit out the HTML Control Characters (“%7B” is “{“, %7D is “}” and “%2D” is “-”) …

    Of course you don’t need the curly brackets for the above example, but you will need to swap in the hyphens.

    Hope this helps …

  • Stuart

    And here is the URL you’ll want to use to fill the global announcements from a linked source in step 8c.

    http://mySharePointServer.com/{@FileDirRef}/DispForm.aspx?ID={@ID}

    This makes sure your list has the correct absolute URL to the linked item (meaning you can have more than one list source in your linked datasource.
    Format the body as rich text, and have paging set to ‘All items’ and you have a globally rolled up announcement list.