1
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="c4b14799-8b38-4951-a24b-1545262b1056.MenuItemCustomAction1"
            RegistrationType="List"
            RegistrationId="101"
            Location="EditControlBlock"
            Sequence="10001"
            Title="Popup;">

 <UrlAction Url="~appWebUrl/Pages/Default.aspx?{StandardTokens}&amp;SPListItemId={ItemId}&amp;SPListId={ListId}&amp;SPSource= {Source}&amp;SPListURLDir={ListUrlDir}&amp;SPItemURL={ItemUrl}" /> 
  </CustomAction>
</Elements>

When I try:

Url="javascript:window.open('http://www.google.com','_blank')"

It encounters error:

Error occurred in deployment step 'Install app for SharePoint': There were errors when validating the App Package.

I want the target site to appear on a new window/ popup.

1

The same problem is already asked here: Call JavaScript function for a custom action in an app for SharePoint 2013

to cite the same MSDN article:

CustomAction cannot contain JavaScript: Any UrlActions or CommandActions must be a URL to navigate to. The URL can be parameterized with normal custom actions tokens in addition to the app-specific tokens.

The question is: What do you want to achieve?

When you just want to use a popup then you could open a Modal Dialog and link to a page inside of your app which executes what you want to do (for example open google.com). So your xml should propably look like this

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <CustomAction Id="c4b14799-8b38-4951-a24b-1545262b1056.MenuItemCustomAction1"
            RegistrationType="List"
            RegistrationId="101"
            Location="EditControlBlock"
            Sequence="10001"
            Title="Popup;"
            HostWebDialog="true"
            HostWebDialogHeight="500"
            HostWebDialogWidth="800">

        <UrlAction Url="~appWebUrl/Pages/MyPageToGoogle.aspx" /> 
    </CustomAction>
</Elements>

I haven't tested it but it should work. Also described here: http://www.codeproject.com/Articles/754808/Open-SharePoint-App-Url-as-a-Modal-Dialog-in-Share

Update:

In your custom action example you refer to the following page:

<UrlAction Url="~appWebUrl/Pages/Default.aspx?{StandardTokens}...">

You say the popup doesn' show the page. Propably you get the following error

iframes no allowed on sharepoint

if that happens you need check on that page if you have the following tag inside:

<WebPartPages:AllowFraming ID="AllowFraming" runat="server" />

If not then inlcude it in the first line of this tag:

<asp:Content ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <WebPartPages:AllowFraming ID="AllowFraming" runat="server" />    
    ** other stuff **    
</asp:Content>
  • I have add HostWebDialog="true" HostWebDialogHeight="500" HostWebDialogWidth="800" into the description. However there are blue cruse underline the attributes and say the attributes are not declared. Luckily, the app can be deployed but a dialog with title only. – user48429 Nov 5 '15 at 9:10
  • TYPO : should be blue curve underline – user48429 Nov 5 '15 at 9:27
  • the blue curve just means that the xml definition does not know this attribute. and of course the page you are refering to should exist! – Sebastian Schütze Nov 5 '15 at 10:53
  • but the dialog still cannot show the page. – user48429 Nov 6 '15 at 1:19
  • please refer to my update in the post! – Sebastian Schütze Nov 10 '15 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.