I am trying to create a SharePoint hosted app(for Sp 2013 & 0365) in VS 2013 for adding a ribbon action to site pages, to be shown while editing pages in it.

I am able to populate the button on the edit menu of a page by using the below code:

      <Button Id="Ribbon.EditingTools.CPInsert.Media.RibbonCustomAction1Button"
              LabelText="Request RibbonCustomAction1"
              Image16by16="_layouts/15/images/placeholder16x16.png" />        
    <CommandUIHandler Command="Invoke_RibbonCustomAction1ButtonRequest"
</CommandUIExtension >

But the issue is that I am not able to add CommandAction as below:


and is getting the below error on deployment:

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

And hence the app is not working. Could you please let me know how to call js here?

1 Answer 1


You cannot add anything else but Urls into the CommandAction Property in SharePoint Hosted AddIns (taken from here -> search for 'CustomAction cannot contain Javascript').

An argumentation why Microsoft designed it this way can be found in this article (search for 'CommandAction="javascript:LaunchApp').

It seems that the app package is processed on import and certain urls get enhanced to enable the ~appWebUrl Token.

Possible duplicate with:


  • thanks for the update @tashunko. the ultimate aim to have an java script action to execute on the button click. so please let me know for any alternative approaches for achieving it. thanks in advance
    – Scarlet959
    May 17, 2017 at 17:28

Your Answer

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

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