6/27/2009

SharePoint: Redirecting to a page after adding a New item to a list

 

There are times when you want a user to add an item to a list without displaying the list, either before or after they fill out the “New Item” form.

 image

To get them to the form is easy. Go to the list, click the New button and note the URL. Copy the URL and paste it as a link in Quick Launch, an Announcement, a links list or a Content Editor Web Part.

image

When the user clicks your link they will go directly to the New item page. But… when they click OK they will go to the list, not back to your page.

 image

 

The fix is easy...        Add “source=” to the end of the link.

 

1) Go to the list and click the new button. You will see a URL like:

http://www.yourserver.com/sites/sales/Lists/Tasks/NewForm.aspx?RootFolder=%2FLists%2FTasks&Source=http%3A%2F%2Fwww.yourserver.com%2Fsites%2Fsales%2FLists%2FTasks%2FAllItems%2Easpx


2) copy the URL and change the part after Source= to the desired destination. The following will send them back to your home page:

http://www.yourserver.com/sites/sales/Lists/Tasks/NewForm.aspx?RootFolder=%2FLists%2FTasks&Source=http%3A%2F%2Fwww.yourserver.com%2Fsites%2Fsales

 

Absolute or Relative?

Best practice would be to use a relative URL (no HTTP or server name) so your site will work when you have internet and intranet access to the same site. Something like "Source=/sites/sales/" or "Source=/sites/sales/mycustompage.aspx".

To return to the home page add this URL as a link in your Announcement, a links list or a Content Editor Web Part:

Absolute:

http://www.yourserver.com/sites/sales/Lists/Tasks/NewForm.aspx?RootFolder=%2FLists%2FTasks&Source=http%3A%2F%2Fwww.yourserver.com%2Fsites%2Fsales

Relative:

/sites/sales/Lists/Tasks/NewForm.aspx?RootFolder=%2FLists%2FTasks&Source=%2Fsites%2Fsales


In the examples above I did not always escape the slashes:  /  =  %2F
Any slash after the "?" should be escaped.

 

 

Redirect the Cancel Button

One of the questions below notes that the redirect steps above redirect both the OK and the Cancel button to the “Source” URL.  Here’s is a quick pass at adding a “CancelDestination” parameter to the query string to set the destination for the cancel button.

Steps:

  1. Go the “New Item” page
  2. Edit the URL and add “&ToolPaneView=2” to the end of the URL to put the page in edit mode
     
    http://yourserver/sites/sales/Lists/Announcements/NewForm.aspx?RootFolder=%2fsites%2fsales%2fLists%2fAnnouncements&Source=http%3a%2f%2fyourserver%2fsales%2fyoursite&ToolPaneView=2
     
  3. Click “Add a Web Part” and add a Content Editor Web Part (CEWP)
  4. Move the CEWP below the existing list web part
  5. Edit the CEWP and click the Source Editor button
  6. Paste the JavaScript from below
  7. Save your changes and exit the edit mode of the page
  8. Create a URL similar to the one earlier in the article, but add a new parameter named “&CancelDestination=http://yourcanceldestination"
     
    http://www.yourserver.com/sites/sales/Lists/Tasks/NewForm.aspx?RootFolder=%2FLists%2FTasks&Source=http%3A%2F%2Fwww.yourserver.com%2Fsites%2Fsales&CancelDestination=http%3A%2F%2Fwww.yourserver.com%2Fsites%2Fsales%2FCancelPage.aspx
     
  9. Test!

 

The JavaScript:

<script>

var querystring = window.location.search.substring(1);  
var parameters = querystring.split("&");
var QueryString = Array();
for (var i=0;i<parameters.length;i++)
{
  QueryString[parameters[i].split("=")[0]] = parameters[i].split("=")[1];
}
if (QueryString["CancelDestination"] != undefined)
{
  var inputs = document.getElementsByTagName("INPUT");
  for (var i=0; i<inputs.length; i++)
  {
    if (inputs[i].value == "Cancel")
    {
      inputs[i].onclick =
function () {document.location.href = unescape(QueryString["CancelDestination"])}; } } } </script>

 

.

6/24/2009

SharePoint: Removing Group Headings from a View’s Group By

 

When you use grouping in list views SharePoint adds the somewhat redundant field name over and over again for each group heading.

image

Often the group field is pretty obvious. We really don’t need to see Color, Color, Color.

 

To fix this requires SharePoint Designer…

  1. Create the grouped view in the browser as usual
  2. Open the site in SharePoint Designer
  3. Find the view file: “yourname.aspx”
  4. Double-click the file to open it for editing
  5. Display the Code view of the file
  6. Search for GroupByField
  7. Delete all of this text:
    &lt;GetVar Name="GroupByField" HTMLEncode="TRUE"/&gt;&lt;HTML&gt;&lt;![CDATA[&lt;/a&gt; :&amp;nbsp;]]&gt;&lt;/HTML&gt;
  8. Display the Design view and confirm that the change is what you wanted.
  9. Save the file
  10. Test in the site in the browser

Notes:

  • Make sure you get all of the text above, and no more.
  • This will remove all group by headings in the view. You can’t remove just one level.
  • Using SharePoint Designer is always at your own risk!  :-)
  • Remember that you can always right-click an edited file in the folder list and select “Reset to site definition” to undo all of your changes.
  • And finally, this is just a view. You can always delete it are start over.

 

The result should look like this:

image

 

.

6/21/2009

SharePoint: How Microsoft did it…

 

It’s always interesting to see how SharePoint sites have been built. This is especially interesting if you would like to see how to integrate Silverlight with SharePoint.

 

From the Microsoft SharePoint Team Blog: “How We Did It: SharePoint.Microsoft.com”

http://blogs.msdn.com/sharepoint/archive/2009/06/18/how-we-did-it-sharepoint-microsoft-com.aspx

6/14/2009

SharePoint: BigDocumentRepository - Big Document Repository

 

Anybody know what a “Big Document Repository” is?

If you do, leave a comment and let us all know what it is!

 

The only places I can find any references to it are:

SharePoint: A few notes on Excel Services

 

 

Some thoughts on Excel Services

(while I’m thinking about Excel services classes)

 

Audiences? Who needs to know what about Excel Services?

* = any one or all of these people need this knowledge.

  Administrators need to know:

  • Server deployment - SSP, load monitoring and load balancing, session issues
  • Setting up Trusted Locations - and setting timeout, UDF and other options
  • How to deploy custom UDFs (User Defined Functions written in .Net)
  • * Know how to maintain Data Connection Libraries and create Data Connection Files (and understand authentication options)

  Site Owners need to know:

  • Excel and Filter web parts
  • Library "Browser-enabled Documents - Display as a Web page" options
  • Who to ask to know where the "trusted locations" are and which UDFs are installed
  • * Know how to maintain Data Connection Libraries and create Data Connection Files (and understand authentication options)

  End users / Excel developers need to know:

  • What Excel Services is really for, and what the limitations are
  • Which versions of Excel can be used to Publish to SharePoint (only 2007 and only editions above Professional)
  • How to publish to SharePoint
  • Which Excel features will not work in Excel Services (VBA macros for example)
  • How to use custom UDFs written by .Net developers
  • * Know how to create Data Connection Files (and understand authentication options)

  Developers:

  • How to write and deploy UDFs
  • How to call the Excel Server web services (there is no object API!)

 

Links:

Features not supported by Excel Services:
http://msdn.microsoft.com/en-us/library/ms496823.aspx

 

 

.

SharePoint: Microsoft Office can remember your My Site?

 

The following applies to SharePoint 2007.

When you first create a My Site, SharePoint will ask you:

“Microsoft Office can remember your My Site to synchronize documents store here in Outlook and to show it when opening and saving files.”

clip_image002

 

What does that mean? Simply, you’ll get a new shortcut on your file open and save dialog boxes that gives you a direct link to your My Sites site.

clip_image002[6]

 

And if your SharePoint server administrator has added “Published Links to Office client applications” you may find additional links to SharePoint content in file open and save dialog boxes and in data connection dialog boxes.

 

.

6/10/2009

SharePoint: Hide List and Library Column Headings

 

Updated 1/13/2012 with notes for SharePoint 2010

A 2013 version of this article is available here: http://techtrainingnotes.blogspot.com/2015/07/sharepoint-2013-hide-list-and-library.html

I had a request for hiding the column headings of a list displayed in a web part. First thought was the toolbar, but they were asking about the clickable column headings. I think they were wanting to make a page look more like a regular web page instead a page full of lists. By the way this makes for a better way to display a view with only one column…

Note: This will of course remove the ability of the site visitor to sort and filter the web part.

Note: This will also work right in the view page (view pages use web parts!), but in SharePoint 2010 adding a web part to a view page will change how the ribbon gets displayed and will remove the View dropdown menu from the title area crumb trail.

 

Before (2007):

image

After (2007):

image

 

Before (2010):

image

After (2010):

image

Note: after this customization the checkbox column disappears, at least until you mouse over a document. Bug? I think it’s a bonus!

 

Steps:

  • Add your web part for the list to a page
  • For a minimal look set the toolbars to “none”
  • Below this web part add a Content Editor Web Part (CEWP)
    • Modify the CEWP and use the Source Editor button
    • Copy an paste the JavaScript below
    • If the CEWP displays it’s title bar then in the Appearance section set the Chrome to “none”
  • Or (preferred for SP 2010 other than view pages)
    • Copy the JavaScript to a Notepad file (name it something like “HideHeading.html”) and upload this file to a library
    • In the library where you uploaded this file, right-click this file and copy it’s shortcut / url
    • Below your web part add a Content Editor Web Part (CEWP)
    • Modify the CEWP and paste the URL copied above into the Content Link box
    • Save your changes
  • Or (for SharePoint view pages)
    • Edit the view page in SharePoint Designer
    • Copy and paste the Javascript to just before the end tag for PlaceHolderMain (just before </asp:Content>)
  • If you want to hide the column headings of multiple web part modify the IF statement like this Three web parts

Web part summary name!

In SharePoint 2007, the summary name is usually just the list’s name: “Shared Documents”.

In SharePoint 2010, the summary name is usually the list’s name PLUS the list’s description. For example the default for Shared Documents is: “Shared Documents Share a document with the team by adding it to this document library.”  (including the period)

To find the correct name use your browser’s View Source option to display the HTML of the page and search for “summary=” and copy the text that follows.

    <table summary="Shared Documents Share a document with the team by adding it to this document library."

The JavaScript

 

Need to change multiple web parts?

Two web parts:
             if (x(i).summary=="Tasks" | x(i).summary=="Shared Documents"
Three web parts:
             if (x(i).summary=="Tasks" | x(i).summary=="Links" | x(i).summary=="Shared Documents"

The JavaScript

<script type="text/javascript"> // CEWP trick from techtrainingnotes.blogspot.com!

// techtrainingnotes.blogspot.com/2009/06/sharepoint-hide-list-and-library-column.html // Hide column headings in web parts //Find the list (change "Shared Documents" to your web part's name) var x = document.getElementsByTagName("TABLE"); // find all of the Tables var i; var y; for (i=0;i<x.length;i++) { if (x[i].summary=="Shared Documents") //find the table with this name { y = x[i].getElementsByTagName("TR"); y[0].style.display="none"; //hide the first row } } </script>

 

 

.

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.