UrlAction Element (Custom Action)

Specifies the page URL for an action.

<UrlAction
  Url = "Text">
</UrlAction>
Attributes

Attribute Description

Url

Required Text. Specifies the site or site collection relative URL of the page, for example, ~site/_layouts/sampleurl.aspx or ~sitecollection/_layouts/sampleurl.aspx.

Child Elements

None

Parent Elements

Occurrences

Minimum: 0

Maximum: 1

Remarks

Example

For an example of how this element is used, see Custom Action Definitions.

Tags :


Community Content

qtejane
Pass itemId and ListId through CustomAction

To build a custom action that points to the edit form of a single list/doc lib when selecting a list item you need to pass the itedmid and listid in the urlaction url.

Use the registrationId if you only want to have the feature for lists based on that particular content type.

<CustomAction
Id="MyId"
RegistrationType="ContentType"
RegistrationId="0x0101[Guid]"
Location="EditControlBlock"
ImageUrl="/_layouts/images/EDIT.GIF"
Sequence="106"
Title="Edit Procedure">
<UrlAction Url="~site/MyList/Forms/EditForm.aspx?ID={ItemId}&amp;List={ListId}"/>
</CustomAction>


DinSoft
urlaction source redirect
I couldn't find documentation or examples to stick the current page url into the query string like the ItemId and ListId are. Jan Tielen (http://weblogs.asp.net/jan/archive/2007/09/05/using-the-current-page-url-in-the-urlaction-of-a-sharepoint-feature.aspx) describes how to instead insert the current page url with a javascript url:

<UrlAction Url="javascript:window.location='{SiteUrl}/_layouts/mypage.aspx?List={ListId}&amp;Source=' + encodeURIComponent(window.location)"/>

This enables you to use <Template_Buttons>'s Cancel button.

The FEATURES folder also contains some url actions with the site-collection url like
<UrlAction Url="_Layouts/RedirectPage.aspx?Target={SiteCollectionUrl}_catalogs/masterpage" />


Michael Bollhoefer
You Receive a List Does Not Exist Error When Using the {ListId} Token

I have a blog post about this error at http://sharepointinsight.com/blog/Lists/Posts/Post.aspx?ID=32.

Here is most of the post:

I was building a feature that simply redirects a user to an ASPX Web Part page to allow some processing of items within that list. I needed to know which list that the user came from so I could open the list and execute some code to get my result. Simple right? When you create your features custom action simply use the token {ListId} in the UrlAction property. This actually works great. However, what you don't want to do, and what was causing me so much grief, is use the word list as your query string variable name. I used the following UrlAction: <UrlAction Url="/MyCustomPage.aspx?list={ListId}"/>. Every time I clicked on my features link it would throw the following error on the next page.

ERROR

List does not exist

The page you selected contains a list that does not exist. It may have been deleted by another user.

After much frustration I finally started playing with the query string and noticed that if I changed the word list everything started working instantly. Enter a moment of OHHHHHHHHHH THAT'S THE PROBLEM. So, now feeling enlightened that this seems to be a reserved query string by SharePoint I changed my UrlAction to <UrlAction Url="/MyCustomPage.aspx?listID={ListId}"/> . Presto everything works and I am happy that I can move on to customizing more of the menu. I have not tested to see if other tokens such as {SiteId} or {ItemId} cause the same problems with there respective query strings. So be careful using those as well. When in doubt make sure it's different from what SharePoint is using.


austegard
List of URL Action Tokens
Hristo Pavlov has compiled a list of the URL Tokens used by the CustomAction feature here: http://hristopavlov.wordpress.com/2008/12/08/urlaction-tokens-of-the-customaction-feature/


TokenReplaced By~site/SPContext.Current.Web.ServerRelativeUrl~sitecollection/SPContext.Current.Site.ServerRelativeUrl{ItemId}item.ID.ToString(){ItemUrl}item.Url{SiteUrl}web.Url{ListId}list.ID.ToString(“B”){RecurrenceId}item.RecurrenceID


Thomas Lee
Safari Browser problem with "&"in UrlAction

SAFARI Browser...Please help!! Below works for IE and firefox but for safari for windows the 2nd query string value will not work because safari renders the &amp as "&amp;" instead of "&" I tried using &#38 but this dis not work either....Any ideas?

<UrlAction Url="~site/_layouts/SpecialActionsXY/MySpecialActionXY.aspx?List={ListId}&amp;ID={ItemId}"/>

[tfl - 07 08 09] Hi - and thanks for your post. You should post questions like this to the MSDN Forums at http://forums.microsoft.com/msdn or the MSDN Newsgroups at

http://www.microsoft.com/communities/newsgroups/en-us/ . You are much more likely get a quicker response using the forums than through the Community Content. For specific help about:
Visual Studio :
http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public.vstudio%2C &
SQL Server :
http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public.sqlserver%2C &
.NET Framework :
http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public.dotnet.framework
PowerShell : http://groups.google.com/group/microsoft.public.windows.powershell/topics?pli=1
All Public : http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public%2C &


Page view tracker