1,804 articles and 14,828 comments as of Tuesday, May 10th, 2011

EndUserSharePoint has combined resources with NothingButSharePoint.com. You can now find End User (Mark Miller), Developer (Jeremy Thake) and IT Pro SharePoint content all in one place!

This site is a historical archive and is no longer being updated. Please update your favorites, bookmarks and RSS feeds.

NothingButSharePoint.com
Thursday, October 22, 2009

Taming the Elusive “Calculated Column” – Referencing a Multiple Lines of Text Column With Append Text: Part 2

In Part 1, Dessie gave us the first six steps "How to reference a ‘Multiple Lines of Text’ column in a ‘Calculated Column’ to display a complete list of appended changes to all items on a list as a group – in 10 Easy Steps”. Now we pick up where he left off with Step 7:

Step 7: The “Magic” URL

In order to be able to view the complete list of versions in an items history, you needn’t look any further than the magic URL of “?IncludeVersions=TRUE”.  Why this wasn’t made as a directly accessible option in views I’ll never know, but suffice it to say, all you need to do is add this to the end of your list view URL and watch the magic happen.

http://[Your-Domain]/Lists/All%20Comments/AllItems.aspx?IncludeVersions=TRUE

Append Text

Of course, it may make more sense if you add in the “Version” column to your view:

Append Text

Notice how the most recent version is the one listed first?

Step 8: My Memory is full!!

Although this approach is “technically” working, it’s not really the best tactic (as it is) since you’ll have to remember what that “Magic URL” is and paste it in each time you want to view the list of versions. 

To remedy this, we’ll create a separate view and use some simple JavaScript to append on the “Magic URL” to our target page.

Start by creating a new view called “Comments View” and add in the columns “Title (linked to item with edit menu)”, “Expanded Comments”, and “Version”. 
Additionally, scroll down to the “Group By” section and choose “Title” for the first group by column and choose “Expanded” for the default “Show Groupings” setting.

This will display as:

Append Text

Next, we need to add in the “Magic URL” to our link for this view so it automatically displays the complete version list when we get there.

Choose the “All Items” view from the View dropdown to return to the default view page. 

Once there, go into the CEWP, open its “Source Editor” and right before the closing “script” tag, add in the following:

var items = document.getElementsByTagName('ie:menuitem');
  for(var i=0; i<items.length; i++)
  {
  if(items[i].id == "zz30_View1")
  {
  var itemAtt = items[i].attributes;
  var newAtt = itemAtt.onMenuClick.value;
  itemAtt.onMenuClick.value = newAtt.replace(/aspx/,  "aspx?IncludeVersions=TRUE");
  }
  }

Note – the above referenced “ID” of “zz30_View1” is what I’ve noticed to be the default id given to the first custom view created (the “All Items” view always seems to get “zz29_View1”).  I just wanted to mention that here in case it doesn’t work for you, you may need to view the page source to find the appropriate ID.

Once saved, clicking on the “Comments View” from the view dropdown will now take you to the view, but also have the “Magic URL” appended to it which will expand out the list of comments for viewing:

Append Text

Step 9: Test Round 2

Once we have this set up, go back to the list and create several new items – each with several edits to make a history of comments.

Append Text

Till next time…
– Dessie

In his next post, Dessie gets us to step 10 and cleans everything up.

Dessie LunsfordDessie Lunsford
Points-of-Sharing 

View all entries in this series: Dessie Lunsford-Logic Formulas»
Entries in this series:
  1. Taming the Elusive "Calculated Column"
  2. EndUserSharePoint.com: Taming the Elusive "Calculated Column" - Customizing a Task List
  3. EndUserSharePoint.com: Taming the Elusive “Calculated Column” - Customizing a Task List (Part II)
  4. EndUserSharePoint.com: Taming the Elusive “Calculated Column” - Customizing a Task List (Part III)
  5. EndUserSharePoint.com: Taming the Elusive “Calculated Column” - Customizing a Task List (Part IV)
  6. EndUserSharePoint.com: Taming the Elusive “Calculated Column” - Text and Data
  7. EndUserSharePoint.com: Taming the Elusive "Calculated Column" - Customizing a Contacts List (Part I)
  8. EndUserSharePoint.com: Taming the Elusive "Calculated Column" - Customizing a Contacts List (Part II-I)
  9. EndUserSharePoint.com: Taming the Elusive “Calculated Column” - Customizing a Contacts List (Part II-II)
  10. EndUserSharePoint.com: Taming the Elusive “Calculated Column” - Customizing a Contacts List (Part II-III)
  11. EndUserSharePoint.com: Taming the Elusive “Calculated Column” – Text and Data (Part III)
  12. EndUserSharePoint.com: Taming the Elusive “Calculated Column” – Text and Data (Part IV)
  13. EndUserSharePoint.com: Taming the Elusive “Calculated Column” – Text and Data (Part V)
  14. EndUserSharePoint.com: Taming the Elusive “Calculated Column” – Text and Data (Part VI)
  15. Taming the Elusive “Calculated Column” – Lookup and Reference
  16. Taming the Elusive “Calculated Column” - Logic
  17. Taming the Elusive “Calculated Column” - Logic - Part 1
  18. Taming the Elusive “Calculated Column” - Logic - Part 2
  19. Taming the Elusive “Calculated Column” - Logic - Part 3
  20. Taming the Elusive “Calculated Column” - Logic - Part 4
  21. Taming the Elusive “Calculated Column” - Logic - Part 5
  22. Taming the Elusive “Calculated Column” - Logic - Part 7
  23. Taming the Elusive “Calculated Column” - Logic - Part 6
  24. Taming the Elusive “Calculated Column” - Logic - Part 8
  25. Taming the Elusive “Calculated Column” - Logic - Part 9
  26. Taming the Elusive “Calculated Column” - Logic - Part 10
  27. Taming the Elusive “Calculated Column” - Date and Time - Part 1
  28. Taming the Elusive “Calculated Column” - Date and Time - Part 2
  29. Taming the Elusive “Calculated Column” - Date and Time - Part 3
  30. Taming the Elusive “Calculated Column” - Date and Time - Part 4
  31. Taming the Elusive “Calculated Column” - Referencing Multiple Lines of Text Column
  32. Taming the Elusive “Calculated Column” – Date and Time – Part 5
  33. Taming the Elusive “Calculated Column” – Date and Time – Part 6
  34. Taming the Elusive “Calculated Column” – Date and Time – Part 7
  35. Taming the Elusive "Calculated Column" - Referencing a Multiple Lines of Text Column With Append Text: Part 1
  36. Taming the Elusive "Calculated Column" - Referencing a Multiple Lines of Text Column With Append Text: Part 2
  37. Taming the Elusive "Calculated Column" - Referencing a Multiple Lines of Text Column With Append Text: Part 3
 

Please Join the Discussion

6 Responses to “Taming the Elusive “Calculated Column” – Referencing a Multiple Lines of Text Column With Append Text: Part 2”
  1. Venky M says:

    Is this code incomplete in STEP 8:?

    var items = document.getElementsByTagName(’ie:menuitem’);
    for(var i=0; i

  2. Hmm…the formatting seems to have been broken when Mark rebuilt things. I’ll ping him to get it fixed.

    Meanwhile,
    Here’s the script:

    var items = document.getElementsByTagName('ie:menuitem');
    for(var i=0; i<items.length; i++)
    {
    if(items[i].id == "zz30_View1")
    {
    var itemAtt = items[i].attributes;
    var newAtt = itemAtt.onMenuClick.value;
    itemAtt.onMenuClick.value = newAtt.replace(/aspx/, "aspx?IncludeVersions=TRUE");
    }
    }
    

    - Dessie

  3. Should be working now…

  4. Venky M says:

    Thanks Dessie,

    Please include Sort by Version/Desc while creating custom Comments View in step 8 to complete.

    Somehow the script you have provided not working, So I have modified as shown below:

    // Custom View
    // zz29_View1  (zz30_View1 not appearing in either view)
    var items = document.getElementsByTagName('ie:menuitem');
    for (var i=0;i&lt;=items.length;i++)
    {
      if(items[i].id == &quot;zz29_View1&quot;)
      {
        var itemAtt = items[i].attributes;
        var newAtt = itemAtt.onMenuClick.value;
        itemAtt.onMenuClick.value = newAtt.replace(&quot;Comments View.aspx&quot;, &quot;Comments View.aspx?IncludeVersions=TRUE&quot;);
        break;
      }
    }
    

    But even now, there are two open issueson my list:
    1) I have click twice to get all version shown in action menu. Please let me know, If I am missing anything here.

    2) All Items view does show Expanded Comments as third comment

    Am I missing anything here?

  5. Venky M says:

    Thanks Dessie, Great Article series.

    Ignore my previous request. Partly it is working now and your Part-3 was taking care of version sort order etc.

    1) I have click twice to get all version shown in action menu. Please let me know, If I am missing anything here.

    Thanks Again,
    Venky

  6. Gil Burak says:

    Hi Dessie,

    Excellent article and worked great for SP2007.

    However, we’ve switched to using SP2010 and I’ve been having trouble getting versions to display. Any idea?

    Thanks,

    Gil


Notify me of comments to this article:


Speak and you will be heard.

We check comments hourly.
If you want a pic to show with your comment, go get a gravatar!