Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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!

share|improve this question
    
I take it the most outer quotes around your UrlAction element do not actually appear in your Feature? :) –  Jaap Vossers May 10 '10 at 21:29
add comment

4 Answers

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" />
share|improve this answer
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 May 10 '10 at 20:10
    
Yeah, I think I have seen javascript being used for UrlAction –  Jaap Vossers May 10 '10 at 21:27
add comment

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.

share|improve this answer
add comment

try ~site token instead of {SiteUrl}

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

share|improve this answer
    
That's a good point, 'SiteUrl' isn't a valid token. –  Chris O'Brien - MVP May 10 '10 at 21:45
add comment

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();"/>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.