Skip to main content

Weblog Ton Stegeman [MVP]

Go Search
Home
  

ODC 2008
If you have a question or suggestion, please contact me through Windows Live Messenger.
My status: .

If I am not online, please send me an e-mail.
Weblog Ton Stegeman [MVP] > Posts > Site users WebPart – fixing the ‘add new user’ link
Site users WebPart – fixing the ‘add new user’ link

SharePoint out of the box has the Site Users webpart. This web part allows you to connect to a SharePoint group and show the members of that group. If you have enough permissions, you also get a link “add new user” to add new users to the group. Very nice web part to use in collaborative environments. The web part however has one issue. In the screenshot below, you see I configured it to show the members of the ‘'Editors group’.

image

The webpart shows the members of this group. But when I click the ‘add new user’ link, I end up in the AclInv page, but not in the Editors group. I end up in the first group that is configured in the groups quick launch:

image

For users this is very confusing, because they probably don’t notice this. If you look in the source of the page, you can see the cause of this problem. The <a> element refers to the correct link, which is AclInv.aspx with a GroupId in the querystring:

href="/_layouts/aclinv.aspx?GroupId=66"

The element also has an OnClick event handler that looks like this:

ONCLICK="javascript:NewItem('\u002ftest\u002ft2\u002f_layouts\u002faclinv.aspx', true);javascript:return false;"

The problem is that this link does not contain the GroupId parameter.

The script below fixes this problem. I added this script to a content editor web part. I know, there are better ways to do this… If you also do it in a content editor web part, make sure that this web part is the last webpart on the page.

<script language="javascript">
function FixAddUserLink()
{
  var links = document.getElementsByTagName('a');
  for (var i=0; i<links.length; i++)
  {
    if (links[i].id=='addnew' && links[i].href.indexOf('aclinv.aspx')>0)
    {
      links[i].onclick = 'javascript:NewItem("' + links[i].href + '", true)';
    }
  }
}
FixAddUserLink()
</script>

 

After reloading the page, and clicking the link, I end up in the Add Users page in the group that I expected:

image

Comments

There are no comments yet for this post.
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 *


Your city *


Type the name of the city you live in (making it easier to handle spam...)

CurrentDate *

Select the current date (see if this gives me fewer spam...)
Attachments

 Links

  SharePoint Object on CodePlex
  Screencast introducing SharePoint Objects
  Content by Type and Filter Web Parts on CodePlex
  Archive
  Archive (Calendar)

 My Latest Blog Posts

Scripting SharePoint 2007 setup: choices and conceptsUse SHIFT+ENTER to open the menu (new window).
Adventures in Visual Studio 2010: Migrate the Content By Type web part to SharePoint 2010Use SHIFT+ENTER to open the menu (new window).
Register SharePoint themes by using a featureUse SHIFT+ENTER to open the menu (new window).
SharePoint 2010 development on Windows 2008 Server R2 – Getting StartedUse SHIFT+ENTER to open the menu (new window).
New release SharePoint Objects: features and groupsUse SHIFT+ENTER to open the menu (new window).
Constructing the url to the SharePoint Edit Permissions pageUse SHIFT+ENTER to open the menu (new window).
Screencast: introduction to SharePoint ObjectsUse SHIFT+ENTER to open the menu (new window).
SharePoint 2007 and Reporting ServicesUse SHIFT+ENTER to open the menu (new window).
SharePoint Objects – Insight in usage of your SharePoint artifactsUse SHIFT+ENTER to open the menu (new window).
SharePoint 2007 Custom list schema and the Content Query Web PartUse SHIFT+ENTER to open the menu (new window).
SharePoint 2010 Silverlight Client Object Model – ExecuteQuery vs ExecuteQueryAsyncUse SHIFT+ENTER to open the menu (new window).
SharePoint 2010, the Client Object Models and Bing MapsUse SHIFT+ENTER to open the menu (new window).
Having fun with SharePoint 2010, Silverlight 3 and Bing MapsUse SHIFT+ENTER to open the menu (new window).
Connecting TFS 2010 projects to SharePoint sitesUse SHIFT+ENTER to open the menu (new window).
Adding a database to the SharePoint database Server using SPDatabaseUse SHIFT+ENTER to open the menu (new window).