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?

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

  • 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 Aug 28 '14 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

  • I tried to play around this topic. It didn't help. The problem I think in the validation rules of SharePoint online. – Alexander Sep 26 '14 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.

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

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.