Skip to main content
added 462 characters in body
Source Link
Mihail
  • 2.1k
  • 14
  • 19

The ScriptSrc attribute is only applicable when the Location attribute is set to ScriptLink.

What you need to do is to remove the ScriptSrc attribute from your custom action, and then create an additional custom action that serves the script. See below:

<CustomAction Id="ScriptSource1"
              ScriptSrc="/mysite/siteAssets/function.js"
              Location="ScriptLink"
              Sequence="100">
</CustomAction>

If you do not want to have 2 custom actions due to performance concerns, then you need to write JS code that loads the JS file and then executes your function. That JS code would have to be placed inside CommandAction attribute like this:

CommandAction="javascript: <JS code that loads JS file from Site Assets>;
                           JsFunctionInJsFileInSiteAssets();"

You may want to use dynamic loading, namely the SP.SOD.registerSod and SP.SOD.executeFunc functions. See third link in the references below.

Or if the code in the JS file is not too large, you could get rid of the JS file and place your entire code inside the CommandAction attribute.


References:

The ScriptSrc attribute is only applicable when the Location attribute is set to ScriptLink.

What you need to do is to remove the ScriptSrc attribute from your custom action, and then create an additional custom action that serves the script. See below:

<CustomAction Id="ScriptSource1"
              ScriptSrc="/mysite/siteAssets/function.js"
              Location="ScriptLink"
              Sequence="100">
</CustomAction>

If you do not want to have 2 custom actions, then you need to write JS code that loads the JS file and then executes your function. That JS code would have to be placed inside CommandAction attribute like this:

CommandAction="javascript: <JS code that loads JS file from Site Assets>;
                           JsFunctionInJsFileInSiteAssets();"

References:

The ScriptSrc attribute is only applicable when the Location attribute is set to ScriptLink.

What you need to do is to remove the ScriptSrc attribute from your custom action, and then create an additional custom action that serves the script. See below:

<CustomAction Id="ScriptSource1"
              ScriptSrc="/mysite/siteAssets/function.js"
              Location="ScriptLink"
              Sequence="100">
</CustomAction>

If you do not want to have 2 custom actions due to performance concerns, then you need to write JS code that loads the JS file and then executes your function. That JS code would have to be placed inside CommandAction attribute like this:

CommandAction="javascript: <JS code that loads JS file from Site Assets>;
                           JsFunctionInJsFileInSiteAssets();"

You may want to use dynamic loading, namely the SP.SOD.registerSod and SP.SOD.executeFunc functions. See third link in the references below.

Or if the code in the JS file is not too large, you could get rid of the JS file and place your entire code inside the CommandAction attribute.


References:

Source Link
Mihail
  • 2.1k
  • 14
  • 19

The ScriptSrc attribute is only applicable when the Location attribute is set to ScriptLink.

What you need to do is to remove the ScriptSrc attribute from your custom action, and then create an additional custom action that serves the script. See below:

<CustomAction Id="ScriptSource1"
              ScriptSrc="/mysite/siteAssets/function.js"
              Location="ScriptLink"
              Sequence="100">
</CustomAction>

If you do not want to have 2 custom actions, then you need to write JS code that loads the JS file and then executes your function. That JS code would have to be placed inside CommandAction attribute like this:

CommandAction="javascript: <JS code that loads JS file from Site Assets>;
                           JsFunctionInJsFileInSiteAssets();"

References: