Can't launch script on context menu item click in SharePoint Online

Helllo!

I need help with SharePoint Online.

I try to add item to context menu (in Document Library - I need it in all of document libraries). So I created Visual Studio SharePoint Solution, added MenuItem CustomAction and inserted this text:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
 <CustomAction Id="3141d54f-0b5d-4912-aa1a-2bee8d6d51fd.MenuItemCustomAction"
            RegistrationType="List"
            RegistrationId="101"
            Location="EditControlBlock"
            Sequence="10001"
            Title="CustomMenu">
   <!-- 
   Update the Url below to the page you want the custom action to use.
   Start the URL with the token ~remoteAppUrl if the page is in the
   associated web project, use ~appWebUrl if page is in the app project.
   -->
   <UrlAction Url="javascript:console.log('Works');" />
 </CustomAction>
</Elements>

And every time I try to insert any script in UrlAction parameteres, I get an error:

"Error occurred in deployment step 'Install SharePoint Add-in': There were errors when validating the App Package."

Please, advise, how to insert javascript action in SharePoint Add-In. I don't need my app to redirect me somewhere.

Thank you!

javascriptc#sharepoint-online

Answers

comments powered by Disqus