2

I've tried to update SharePoint hosted app to a new version. It works great on SharePoint on-premises, but on SharePoint online I have a strange behavior - I've got the error

There was a problem accessing the file system on the server. Details: The URL of Custom Actions deployed by apps may not contain javascript or data URI.

In custom action of the app I have this handler

<CommandUIHandler Command="assembly.AssignToMe.Button.Command"
          CommandAction="javascript: CustomAction.assignToCurrentUser();"
          EnabledScript="javascript: CustomAction.enableDisableAssignToCurrentUser();">
</CommandUIHandler>

I've tried to remove the custom action from a new version, but I've got the same exception.

How can I solve this issue?

3 Answers 3

1

According to MSDN (search for CustomAction on page) you are not allowed to put Javascript in a CommandAction, only URLs are expected there, this is how the App model works. However it does work with SharePoint on-premise.

  • 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.
    • EnabledScript is not allowed in ribbon customizations

You can have your action open a modal and then execute your code in the modal.

Hope this helps

1
  • according to MSDN this restrictions are applied to the host web, but in my case the custom action is included to the list which locates on the app web. Furthermore, both versions of the solution can be deployed successfully and they works correctly. The issue appears only on update state.
    – Alexander
    Commented Aug 28, 2014 at 7:10
0

Since your Custom Action is on the app web, I think that there is a problem in your update markup. It is not actually changing the Custom Action, so the old Custom Action is still there. Please see this MSDN article: How to: Update app web components in SharePoint 2013

1
  • I tried to play around this topic. It didn't help. The problem I think in the validation rules of SharePoint online.
    – Alexander
    Commented Sep 26, 2014 at 7:50
0

As it turned out, you still can add custom action with JavaScript in CommandAction and with EnabledScript attribute using JSOM or SSOM. Check this example, it works for me.

1
  • if I'm not wrong it is fixed now.
    – Alexander
    Commented Apr 28, 2015 at 19:16

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.