The expression language used in skybow Solution Studio and Add-ins is very powerful because it allows you to use any JavaScript code. In many cases you might not want to implement all the JavaScript code yourself but reuse some JavaScript libraries.
To use any external code you can include an external JavaScript library (or any JavaScript file in fact) in your expressions in your solution:
- upload .js file into the any library. We recommend using sbSolutionAssets library for storing .js files.
Note: If you store .js files in the custom library, make sure this library is added to solution studio and the option 'Package all items of this list as part of the solution' is checked.
- In the expression builder you need to reference the javascript file use the following format in the first lines of the function expression code:
/// <reference path="path-to-js-file" />
The path to the .js file can be web relative URL, server relative URL or full URL. The path to the .js file can be started with the following placeholders:
[[@Web.Url]]
[[@Web.ServerRelativeUrl]]
[[@Site.Url]]
[[@Site.ServerRelativeUrl]]
/// <reference path="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.js" />
On the server-side (Scheduled Actions, Triggered Actions), path to .js file should be the URL from the current site. You can set it as the following:
/// <reference path="SiteAssets/fxparser.min.js" /> --> This is web-relative URL
/// <reference path="/sites/subsite/SiteAssets/fxparser.min.js" /> --> This is server-relative URL, starts with /
/// <reference path="https://devsite.sharepoint.com/sites/subsite/SiteAssets/fxparser.min.js" />
/// <reference path="[[@Web.Url]]/SiteAssets/fxparser.min.js" /> --> Some placeholders can be used
Note: Only Scheduled Actions and Triggered Actions support referencing javascript files on server side.