Current User Name in a link within a SharePoint list
We have a list in MOSS 2007 which contains a number of web links (URLs of external and internal sites). Out of these, some URLs require the logged in user's user name to be placed within specific placeholders within the URL (e.g. http://www.somesite.com/access/[username]/index.aspx). Is there an easy way to accomplish this in MOSS? We have thought of several workarounds
1. Quick and dirty way is to have a link (in the List) that points to an ASPX page, which in turn does a URL re-direction to the correct URL with the login name substituted.
2. Write a custom web part (like a ASP.NET LinkButton control that reads the URL from an XML config file and adds the user name in the appropriate place (this cannot be placed in the list though)
How can I get this accomplished?
Answers
- Yes, Sorry. You can't use here a CalculatedFields, because SharePoint updated CalculatedFields body only if Item is updated or added, but Today and Me on dynamical tokens.
Then you need to create own FieldType with own Rendering pattern.- Marked As Answer byAaron Han - MSFTModeratorFriday, November 13, 2009 9:34 AM
Hi,
As Borozna suggested, you could not use dynamical token like Me/Today in calculate field.
Sine your list has already existed , if you do not wish to create another webpart to display the user link list, you can create a custom field type to extend your list.
Only in this way, then link be can rendered dynamically at run time.
Please refer these articles for Custom Field Type development:
http://msdn.microsoft.com/en-us/library/bb861799.aspx
http://www.codeproject.com/KB/sharepoint/FckEditorSharepoint2.aspx
As you have also motioned URL re-direction, please also see HttpModule solutions, this will do some re-direction logic silently.
Because an HTTP module is always called as part of the page processing pipeline, you should take care the performance design.
If the performance is an important indicator for you please test your module for performance before deploying it.
Some article for HttpModule
http://msdn.microsoft.com/en-us/library/aa719858(VS.71).aspx
Some sample for HttpModule integration with SharePoint
http://vspug.com/dwise/2007/01/08/one-master-to-rule-them-all-two-actually/
Hope this can help.
Best Regards,
-Aaron
- Marked As Answer byAaron Han - MSFTModeratorFriday, November 13, 2009 9:34 AM
All Replies
- Use Calculated field and function "Me" which returns Current user name (http://www.wssdemo.com/_layouts/help.aspx?lcid=1033&cid0=MS.OSS.manifest&tid=MS.OSS.HA01161025&sq=calculated%20column) Good luck ;)
- Thanks for the response. But MOSS doesn't allow me to use the "Me" function in a calculated column.
- Yes, Sorry. You can't use here a CalculatedFields, because SharePoint updated CalculatedFields body only if Item is updated or added, but Today and Me on dynamical tokens.
Then you need to create own FieldType with own Rendering pattern.- Marked As Answer byAaron Han - MSFTModeratorFriday, November 13, 2009 9:34 AM
in MOSS, there's a current user filter web part. In the web part properties, you can select the username field, then there are other settings in there to set the beginning part and end of the URL, which is where you'd put the other parts of the URL. Then, you could connect this web part to another one to send the information to it, such as a RSS feed, etc.
I've written a blog on how to get the current user's weather using this method. This may be something you can try playing with.
http://www.sharepoint911.com/blogs/laura/Lists/Posts/ViewPost.aspx?ID=19
Laura Rogers, MCSE, MCTS
SharePoint911: SharePoint Consulting
Blog: http://www.sharepoint911.com/blogs/laura
Twitter: WonderLauraHi,
As Borozna suggested, you could not use dynamical token like Me/Today in calculate field.
Sine your list has already existed , if you do not wish to create another webpart to display the user link list, you can create a custom field type to extend your list.
Only in this way, then link be can rendered dynamically at run time.
Please refer these articles for Custom Field Type development:
http://msdn.microsoft.com/en-us/library/bb861799.aspx
http://www.codeproject.com/KB/sharepoint/FckEditorSharepoint2.aspx
As you have also motioned URL re-direction, please also see HttpModule solutions, this will do some re-direction logic silently.
Because an HTTP module is always called as part of the page processing pipeline, you should take care the performance design.
If the performance is an important indicator for you please test your module for performance before deploying it.
Some article for HttpModule
http://msdn.microsoft.com/en-us/library/aa719858(VS.71).aspx
Some sample for HttpModule integration with SharePoint
http://vspug.com/dwise/2007/01/08/one-master-to-rule-them-all-two-actually/
Hope this can help.
Best Regards,
-Aaron
- Marked As Answer byAaron Han - MSFTModeratorFriday, November 13, 2009 9:34 AM


