Skip to main content

Blogging about SharePoint

Go Search
Home
Blogging about SharePoint
Public Speaking
  

Michael Blumenthal's BlumenthalIT.NET > Blogging about SharePoint > Posts > Which views can be used when Creating an Alert ?
Which views can be used when Creating an Alert ?

When you create an alert on a list, you have the option of specifying a view which limits which items would trigger the alert.

image

Note however that the list of views you can choose from is a subset of the views available on the list.  In fact, if you don't have any views that are ok to use for alerts, you won't even see the option to select a view.

What are the rules that determine which views are available for use?

Experimentally, my guesses are:

1) It must have a where clause.  All Items views don't show up in the list of views, and it's pointless to use an All Items view because it doesn't filter.

2) It must be a public view, it cannot be a personal view.

3) It cannot involve content approval.

To try to substantiate these guesses, I went to the source with .NET Reflector (http://www.red-gate.com/products/reflector/).

The page to create a new alert is _layouts/subnew.aspx.

Its code-behind is the SubNewPage in the Microsoft.SharePoint.ApplicationPages dll.  This is in Inetpub\wwwrooot\wss\virtualDirectories\<dir for the web app>\app_bin.

You need to open it in Reflector.  Some of the other SharePoint DLL's are in the GAC, so you may need to copy those DLL's out of the GAC into a more accessible place.  To get a dll out of the GAC, use the command prompt to look around c:\windows\assembly rather than windows explorer.  My copy of the Microsoft.SharePoint.dll and Microsoft.SharePoint.Library.dll was c:\windows\assembly\GAC_MSIL\<dll name without extension>/<version number>_<public key token>/

image

Once you have the ApplicationPages DLL open in Reflector, find the SubNewPage class.  Note It inherits from SubNewEditBasePage, so we now look at that base class because SubNewPage doesn't do anything specific to the list of views. 

Within SubNewEditBasePage, there is an InitForm method that walks through the views for the current list, and only adds to the drop down list the views it likes.

image

The code here is a little hard to understand due to the goto's, but some of the details we can pick out are a qualified view is added to the drop down list box in section 58B and that that in order for the view to be listed:

  1. The view cannot have its Hidden property true.  Checked within the 56A section.
  2. The view must have a title - probably the nameless views used by certain list viewing web parts do not (a guess).  Title is checked within the 57B section.
  3. The view must have a where clause.  This is checked in the 5F7 section.  Let's look at GetFilter more closely.

image

Here we can see that if v.Query is not null (which I interpret as "if there is a where clause") and the query does not use the DateRangesOverlap tag, then we can consider the view further, for possible inclusion in the drop down list.

The next thing it does of significance is to call ValidateFilter on the where clause XML. 

image

This is a thin wrapper around ParentWeb.Request.ValidateSubscriptionFilter.

image

Uh oh, it looks like we are getting into unmanaged (non-.NET) code.  Sure enough, this is where we hit the wall:

image

We can't look inside this with .NET Reflector, so this is the end of the line.  If anyone else has information on what the rules are for which views can be used in alerts, please leave a comment.

--Michael

Comments

nice digging

Michael,
Great sleuthing skills. Thanks for sharing the techniques and the results. Who knew? A shame this isn't in the official dogs.
Tom
----------------
Tom Resing
Tom Resing's SharePoint Blog
Http://blogs.Microlinkllc.com/tresing
at 12/28/2008 11:29 AM

Hmm...

We found that if we created a view based off an existing view it would not show up.  If we created it new of off a standard view template, it would show up in the list of views to select from for alert.

Interesting, but not sure why this is the case when the original view we cloned does show up in the drop down...
at 5/21/2009 11:59 AM

Personal views can

Yes personal views can be used.

No all though, but that must be influenced by the same rules as the other ones (that we don't know at full).
at 8/25/2009 3:25 AM

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Title


Body *


Please put your name at the end of your comment as the Name field doesn't display in the main view of the comments.

Name: *


Your name.  If you first name is Michael, please provide initials or the like to clearly distinguish your name from Michael Blumenthal's.
Also, this field does not appear in the main view of the comments.

Need Paid Consulting Services?

Are you interested in engaging a SharePoint consultant for fee-based consulting services?  If so, I can have an Account Executive from my employer contact you.  Other site visitors will not see this column.

Additional Contact Information

Please provide additional contact information if you need a direct response.  Other site visitors will not see this column.

What is tomorrow's date? *

This is a weak CAPTCHA based on advice from a tweet from @ToddKlindt.
Attachments