0

I have a script called Translate.js on my SharePoint online site.

https://xxxx.sharepoint.com/sites/demo/Style%20Library/docs/Scripts/Translate.js

When I use the code below and try to include the script in my CustomAction, it just says that translate is not defined, Basic because it doesn't load my script.

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
    Id="TranslationRibbonExtension"
    ScriptSrc="~SiteCollection/Style%20Library/docs/Scripts/Translate.js"
    Location="CommandUI.Ribbon">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.WikiPageTab.PubPageActions.Controls._children">
          <Button
            Id="Ribbon.WikiPageTab.PubPageActions.TranslationButton"
            Alt="Translate Page"
            Sequence="100"
            Command="Ribbon.WikiPageTab.PubPageActions.TranslationButton.TranslatePage"
            CommandType="General"
            Image16by16="/_layouts/1033/images/formatmap16x16.png" Image16by16Top="-120" Image16by16Left="-32"
            Image32by32="/_layouts/1033/images/formatmap32x32.png" Image32by32Top="-192" Image32by32Left="-224"
            LabelText="Translate Page"
            TemplateAlias="o1"
            ToolTipTitle="Translate Page"
            ToolTipDescription="Translate Page"
            />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler
          Command="Ribbon.WikiPageTab.PubPageActions.TranslationButton.TranslatePage"
          CommandAction="javascript:
            translate('da', 'en', 'Hej mit navn er John Doe!');
          "/>
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>

Can someone tell why ScriptSrc dont load the script?

0

From the documentation of CustomAction:

ScriptSrc:

Optional Text. Specifies a file that contains script to be executed. This attribute is only applicable when the Location attribute is set to ScriptLink.

So you need to do something like Load an external JavaScript file on demand using a Custom Action in SharePoint 2007

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.