1

I am attempting to call an .aspx page from a custom "Actions" menu item that I have added using xml. However, I cannot get the UrlAction path setup correctly. Everything I try fails with the following error:

"Unknown Error"

Here is my UrlAction:

"<UrlAction Url="javascript:window.location='{SiteUrl}/_layouts/Page.aspx'" />"

Does anyone have any ideas on what I'm doing wrong?

Thank you in advance for any help you can provide!

1
  • I take it the most outer quotes around your UrlAction element do not actually appear in your Feature? :) Commented May 10, 2010 at 21:29

4 Answers 4

1

As far as I'm aware, you can't use JavaScript in CustomAction links. However, from your sample it appears you don't need JS - just use:

<UrlAction Url="{SiteUrl}/_layouts/Page.aspx" />
2
  • 1
    While I agree that JS usage is unwarranted here, I have been using it successfully in CustomAction links as a way to append the source url to links. Here's one I'm using: <UrlAction Url="javascript:window.location='{SiteUrl}/_layouts/customforms/custompage.aspx?ListId={ListId}&amp;Source=' + encodeURIComponent(window.location)"/>
    – MBSurf
    Commented May 10, 2010 at 20:10
  • Yeah, I think I have seen javascript being used for UrlAction Commented May 10, 2010 at 21:27
1

Are you getting the Unknown Error when you load the page where you want the custom action to be? Or is when you click through the custom action? If it is the latter, you probably have an error with your destination page. Here's a link to get more useful error information. Obvious disclaimer, you wouldn't want to enable this on a production machine.

1

try ~site token instead of {SiteUrl}

http://msdn.microsoft.com/en-us/library/ms478271.aspx

1
  • That's a good point, 'SiteUrl' isn't a valid token. Commented May 10, 2010 at 21:45
0

For the sample in your question you don't need javascript, just use

<UrlAction Url="~site/_layouts/Page.aspx" />
// or
<UrlAction Url="~sitecollection/_layouts/Page.aspx" />

If you need javascript and maybe are trying to run more than one command you can do it like this

<UrlAction Url="javascript:function process(){var myUrl = SomeFunction();windows.location = 'http://' + myUrl;};process();"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.