Nick Grattan's Blog

About Microsoft SharePoint, .NET, Natural Language Processing and Machine Learning

Archive for the ‘SharePoint Power User’ Category

Logging in as a different user

with 7 comments

When using default.master in SharePoint users have the “Sign in as Different User” menu option on the “Welcome” menu to login as a different user. This is useful when testing security etc.

This menu is often removed when customizing sites – clients we find often do not want these options displayed. So how can you add a link to allow this facility for testing?

The “Sign in as Different User” navigates to the /_layouts/AccessDenied.aspx page, which displays thus:

Accessdenied

You’ll notice the link “Sign in as a different user”. From the browser status bar you can find the target of this link:

Accessdenied2

So, it turns out to login as another user you simply need to navigate to:

/_layouts/AccessDenied.aspx?loginasanotheruser=true

The standard browser username/password dialog box will be displayed without the “Access Denied” page being displayed to the user.

 

 

 

Written by Nick Grattan

December 3, 2008 at 1:11 pm

Posted in SharePoint Power User

Tagged with ,

Changing Order / Hiding Columns in New / Edit Forms

with 31 comments

The default order of columns in New/Edit forms for lists and document libraries is typically the order they are added. In many cases you may want to change this order, or to remove columns from these forms.

Changing the column order is easy but the method depends on whether you have selected “Allow management of content types” for the list. See below if you have this option selected, otherwise you can:

  1. Open the list and select Settings + List Settings
  2. Select the “Column ordering” link under “Columns”.
  3. Use the “Change Field Order” form to change the order of columns.

Colorder1

You can only hide columns if “Allow management of content types” is selected! So, to hide, for example, the “Title” column you can:

  1. Open the list and select Settings + List Settings
  2. Select Advanced settings
  3. Click Yes for “Allow management of content types” and then click OK.
  4. From the list of content types, select the content type the column appears in, e.g. “Item”.
  5. From the list of columns for the selected content type, select the column (e.g. Title).
  6. Select Hidden and click OK.

Colorder2

Even if you have a single content type, selecting the “Allow management of content types” option does no harm, so this should work in all cases.

Note that when displaying the content type there is a “Column Order” link under the list of columns which can be used to change the order of columns.

In this example, “Title” is a required field, but you can still hide it. The form will allow the item to be created or updated even though a value has not been supplied.

Written by Nick Grattan

December 2, 2008 at 3:57 pm

Posted in SharePoint Power User

Tagged with ,

Stubborn Publishing Pages

with 3 comments

This knowledge article describes the limitation with folders in the “Page” publishing document library – they are ignored by the publishing features and all publishing pages are placed in the root. That’s OK, I can live with that.

In a recent project, I wanted to create a new document library (“News Articles”) that used publising to maintain a list of news stories used by the site. So, I create a new document library, enable content types and add the “Page” content type from the “Publishing Content Types” group. Standard stuff…

Next to testing; I create a new item based on the Page content type, select the page layout and create the new item. The list of documents in my news article document library is freshed … and it’s empty. I try again – and again – and the document library remains stubbornly empty. I check the current view (is there a filter?) and permissions (I’m the site collection administrator); no luck.

Sometime later, I list of the content of the standard “Pages” document library created by the publishing feature. Lo and behold – all my new document pages are there! Rather than creating the new pages in my “News Articles” document library it placed them in the “Pages” document library.

So, not only does publishing ignore folders, it also ignores the document library you try to place pages in! We live and learn.

 

Written by Nick Grattan

September 15, 2008 at 3:27 pm

Finding the Id (Guid) for a SharePoint List

with 49 comments

There are times when you need to find the Id (a Guid) of a list – for example, when setting the Task list to be used with SharePoint Designer Workflows (see my blog post here). Here’s a simple way of doing this:

  • Navigate to the SharePoint list using the browser.
  • Select the Settings + List Settings menu command.
  • Copy the Url from the browser address bar into Notepad. It will look something like:

http://moss2007/ProjectX/_layouts/listedit.aspx?List=%7B26534EF9%2DAB3A%2D46E0%2DAE56%2DEFF168BE562F%7D

  • Delete everying before and including “List=”.
  • Change “%7B” to “{”
  • Change all “%2D” to “-“
  • Chnage “%7D” to “}”

You are now left with the Id:

{26534EF9-AB3A-46E0-AE56-EFF168BE562F}

Update: See Ken’s Comment for a simpler solution (thanks!):

A (slightly) easier way if you have MOSS 2007 is to go to the List or Library settings as described above, then right-click on the “Audience targeting settings” or “Information management policy settings” links and choose Copy Shortcut.

You can then paste the URL and there’s no need to decode the GUID. For some reason these links aren’t URL encoded.

Update: These techniques work for SharePoint 2010 Standard/Enterprise editions as well. Using Ken’s tip does not work for SharePoint 2010 Foundation as these list settings options are not available so you’ll need to use my first suggestion in this case.

Update: And it works for SharePoint 2013 too!

Written by Nick Grattan

April 29, 2008 at 11:10 am

Filtering views by Time and Date

with 15 comments

An earlier blog entry describes how to filter List and Document views by date. However, the [Today] function, by default, returns only the date and not the time. Therefore, this solution does not solve mad-tie’s problem of wanting to filter on items created in the last hour.

CAML queries can include time as well as date when using the [Today] function. This is described by this blog by ucsharp. In CAML when using the [Today] function you can use the “IncludeTimeValue” attribute to specify that time as well as date should be used:

<Value Type=”DateTime” IncludeTimeValue=”TRUE”><Today /></Value>

Now, the problem is that you cannot include this attribute through the SharePoint user interface, but it can be done with SharePoint Designer. So, to create a view that displays items created in the last hour:

  • Create a calculated column called “DatePlusHour” of “Date and Time” type using the “Date & Time” format in the list or document library (as done by mad-tie):

=Created+0.0416666666666667

This takes the date/time of when the item was created and adds one hour (1/24 = 0.4166…).

  • Modify the view (e.g. “All Items”) to filter based on [Today]:

Dtfilter01

Now the CAML query so created needs to be manually edited to include the IncludeTimeValue attribute:

  • Run Microsoft Designer and open the site in which the list or document library resides.
  • Locate the list or document library and open the .aspx file associated with the view (e.g. “AllItems.aspx”.
  • Click the Code tab and locate the CAML query associated with the filter (search on “DatePlusHour”).
  • Edit the CAML query to include the IncludeTimeValue attribute. NOTE: Include spaces exactly as show!

   &lt;Gt&gt;
    &lt;FieldRef Name=&quot;DatePlusHour&quot;/&gt;
    &lt;Value Type=&quot;DateTime&quot; IncludeTimeValue=&quot;True&quot;&gt;
     &lt;Today/&gt;
    &lt;/Value&gt;

It should look like the following:

Dtfilter02

WARNING: If the SharePoint user interface is used to modify the view the IncludeTimeValue attribute will need to be readded using the instructions above.

 

Written by Nick Grattan

April 24, 2008 at 1:59 pm

Re-ordering All-day Items in a Calendar

with 8 comments

By default, all-day items will be displayed in the order determined by their physical location in the database table:

CalSort1

A more natural order would be alphabetic – to change the sort order you’ll need to create a list template, modify the manifest file to add the sort order and then load a new list template. Here goes….

  • First navigate to a standard Calendar list and select the Settings + List Settings menu command.
  • Select the Save List as Template command.
  • Enter a name, such as “SortedCalendar” for the filename and template name and click OK.
  • Click the list template gallery link on the “Operation Completed Successfully” form.
  • You will be taken to the “List Template Gallery”. Click the “Sorted Calendar” link for the gallery you just created. Save this down to the file sytem.
  • Use Windows Explorer to rename the file from “SortedCalendar.stp” to “SortedCalendar.stp.cab” – it really is a CAB file!
  • In Windows Explorer double click the CAB file – you will find a single file called mainifest.xml. Copy this into the file system.
  • Use an XML editor (such as Visual Studio) to open the XML file.
  • Search for the following line (look for calendar.aspx):

<View Name=”{895B6132-0327-4FAB-A34B-EFB57FD5E542}” DefaultView=”TRUE” Type=”CALENDAR” RecurrenceRowset=”TRUE” DisplayName=”Calendar” Url=”Lists/Calendar2/calendar.aspx” Level=”1″ BaseViewID=”2″ ContentTypeID=”0x” ImageUrl=”/_layouts/images/events.png”>

  • You now need to look for the query associated with this view. It will be about ten to fifteen lines below the line shown above and looks like:

           <Query>
              <Where>
                <DateRangesOverlap>
                  <FieldRef Name=”EventDate”/>
                  <FieldRef Name=”EndDate”/>
                  <FieldRef Name=”RecurrenceID”/>
                  <Value Type=”DateTime”>
                    <Month/>
                  </Value>
                </DateRangesOverlap>
              </Where>
            </Query>

  •  Edit the CAML query to include a “OrderBy” clause:

            <Query>
              <Where>
                <DateRangesOverlap>
                  <FieldRef Name=”EventDate”/>
                  <FieldRef Name=”EndDate”/>
                  <FieldRef Name=”RecurrenceID”/>
                  <Value Type=”DateTime”>
                    <Month/>
                  </Value>
                </DateRangesOverlap>
              </Where>
              <OrderBy>
                <FieldRef Name=”Title”/>
              </OrderBy>
            </Query>

This will cause the results to be sorted by the “Title” field.

  • Save the file manifest.xml.

The manifest.xml file now needs to be added back into the CAB file using the MAKECAB application. To make this tool more accessible run a Visual Studio Command Prompt:

  • Select the Start + All Program + Visual Studio 2005 + Visual Studio Tools + Visual Studio 2005 Command Prompt.
  • At the command prompt navigate to the folder where the manifest and CAB files are located and enter the following:

makecab manifest.xml SortedCalendar.stp.cab

  • Rename “SortedCalendar.stp.cab” to “SortedCalendar.stp”.
  • Return to the “List Template Gallery” in SharePoint.
  • Click the Upload button and upload the “SortedCalendar.stp” file.

You can now test the new list template by creating a new list– you will find the new listtemplate listed in the Tracking section on the “Create” form. All day events will now be alphabetically sorted by “Title”. Phew!

Written by Nick Grattan

January 23, 2008 at 9:13 pm

Customizing Site Catagories

leave a comment »

In MOSS 2007 sites can be categorized by “Division” or “Region”. When creating a site the user can categorize the site:

Sitecat1

Checking “List this new site in the site directory” will add an item to the “Sites” list in the “Sites” site and the site will therefore be listed in the Site Directory.

You can change the categories in “Division” or “Region” to suite your own organization. This is done by editing the “Division” or “Region” column in the “Sites” list in the “Sites” site.

Not so obvious are the following customizations:

  1. You can rename “Division” or “Region” and this change will be reflected when you add a new site and in the site directory.
  2. You can add new “Choice” type columns to the “Sites” list and these will then be available for categorization.
  3. You can delete the “Division” or “Region” columns if they do not apply to you.

For example, you could add a new Choice column called “Department” and add some choices to this. It will now appear in the Site Directory:

Sitecat2

The choice type uses a combo box when a site is created since multiple selection was prohibited when the column was created:

Sitecat3

 

 

Written by Nick Grattan

January 10, 2008 at 10:23 am

Using the XmlFormView Web Part with InfoPath Forms

with 33 comments

In this earlier post I briefly describe how to embed an InfoPath form in a SharePoint Web Part Page using the XmlFormView web part. I’ve been asked on many occasions to provide a more detailed account.

You can find the step-by-step guide to embedding an InfoPath form in an XmlFormView web part in a white paper here: How to Host Microsoft InfoPath Forms in SharePoint Pages. This document also shows how to create a Submit button to override the normal “Save” option on InfoPath forms.

Updated September 2009: Now includes instructions on creating a web part page using Microsoft SharePoint Designer for XmlFormView web parts. This is much easier than using the browser.

Written by Nick Grattan

December 19, 2007 at 1:31 pm

Error adding Best Bets to Search Keywords

with one comment

Here’s a problem that’s been confusing me for a while. When adding key words to a site collection, clicking the Add Best Bet link sometimes displays the error “The search service is currently offline”:

Bb3

When reading the fix list for SharePoint SP1 I found the answer to this problem. It seems if there is not a site collection in the root of a web application (e.g. “http://moss2007:8100&rdquo;) clicking Add Best Bet in a site with a URL like “http://moss2007:8100/sites/Intranet&rdquo;) will cause this error.

It seems an “Access Denied” error is displayed if the site administrator does not have access to the root site collection when adding Best Bets from a site collection under “sites”. These issues are fixed in SP1.

 

 

 

Written by Nick Grattan

December 18, 2007 at 3:46 pm

Removing the Title from a Web Part Page

with 14 comments

By default, a Web Part Page will display a graphic and heading above the web parts you add. 

WebPageTitle1

This can take up valuable screen space, so to remove it:

  • Navigate to the document library in which the Web Part Page is located.
  • Select the Edit Properties item from the edit menu:

WebPageTitle2

  •  Click the Open Web Page in maintenance view link:

WebPageTitle3

  • Check the Web Part Page Title Bar check box and click Close.

WebPageTitle4

  • Click on Go Back to Web Part Page to ensure the title has been removed.

Note that the Web Part Page is closed and not deleted. This allows you to re-add the title from the closed web part gallery. You can choose to delete it if you want.

Written by Nick Grattan

December 14, 2007 at 12:54 pm