Tools






WSS, doc libs & lists, Calculated columns involving [Me]

Someone on the Internets was asking about how to create a calculated column on a list that would show a value formatted as "[User] – [Status] – [Location]" as in "Paul Galvin – Drinking [free] Beer – The Beach".

Paul would go in and update his entry in the list and the calculated column would update appropriately.  The [User] should default to the the user entering/updating the list.

A calculated column cannot use "volatile" functions such as [Me] or [Today].  I solved it in a test environment with these steps:

  1. Create a text column named "Current User".
  2. Set its default value to [Me]
  3. Create a calculated column called "Calc Test".
  4. Set its value = [Current User]

I went in, added an item to the list and it worked.

9 comments to WSS, doc libs & lists, Calculated columns involving [Me]

  • Ryan

    I don’t think (but have not verified) this will work in SharePoint 2007 – a calculated column is only updated when the item is edited so in this case [Me] will always be the user who last edited the item.

    The same trick using [Today] no longer works – see this post for more details http://blog.pentalogic.net/2008/11/truth-about-using-today-in-calculated-columns/

  • Richard Harbridge

    Darn. Doesn’t look like I can get that ‘workaround’ to show the user information in the column.

  • Richard Harbridge

    Hello Paul,

    Without meaning to I think you just figured out a way to get around a serious InfoPath/SharePoint issue I have been having.

    Basically I can get the domain\username of users but then cannot use [Me] filters and other powerful SharePoint functionality. But by using something like this, it should work around that issue, by allowing me to compare two text columns (single line) rather than a people and groups column.

    Time to give it a try.

    Thank you,
    Richard Harbridge

  • Christophe Humbert
    Am I missing something? Your example shows the user name in clear ("Paul Galvin"), but when I test this I actually get the login (which somehow defeats the purpose, as announcing that "DOMAIN\username is drinking a beer" doesn’t sound that cool…).
  • No name
    Hello.
    I’m trying to use a CAML query against the Sharepoint web services in order to filter the items modified by [Me] and some other options. Do you know how to do that because I haven’t found anything yet?.
    I’ve tried GetListItems with the filtering query and a view that has a filter with  Modified By = [Me], but the view is ignored when using a query.
    Thanks.
  • Patrick Rote
    It did work now but had to add a new item couple of times
  • Patrick Rote
    I did your tirck Paul.
    But when i view the list i see only [Me] and not my username.
    When i created the calculated column i set it to [Current User] using the formula add button.
    Is that right?
    Let me know
    Thanks
  • Paul Galvin
    Sadly, I don’t see any way to do that without writing an event handler.  Even If change the presentation of the "Person or Group"  to simple "Name" (as opposed to the more complex "Name with Presense") it is still disallowed.
     
    –Paul Galvin
     
     
  • Drew

    Paul,
    Thank you for that solution.  It worked great.  Expanding on your solution, would you have any idea how to set calc test = Current User if you want current user to be a People Picker field with only people selected?

    Thanks again.

    Drew

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>