At the moment, the only way to get data in or out of SSJS is via keywords. These only get processed before an SSJS block is executed for data going in -- or after for controlling behaviour afterwards. Whilst fairly straightforward for simple situations (eg passing IDs in as strings), trying to pass a multi-line string (eg asset contents) or datatype is hard, potentially requiring detailed workarounds. Moreover, what isn't possible at present is resolving keywords or querying an API for metadata, page contents, link types, status etc (really any type of data) from within the SSJS so you can use the data to make decisions, perform processing and generate output. Here's a basic contrived example:
var prefix = global ? "gloabls_asset" : "asset"
var assetID = '%' + prefix + '_metadata_setting%' // Won't evaluate unless printed out of SSJS
if (value.match(/Site/) || value === 'other') {
// Do something, like printing children for (child in js_api.getChildren(assetID) { // Doesn't exist print(...)
}
}
The second line will only resolve the keyword after being print()'d, meaning its value can't be used for in further SSJS processing or decision making.
At the moment, the only way to get data in or out of SSJS is via keywords. These only get processed before an SSJS block is executed for data going in -- or after for controlling behaviour afterwards. Whilst fairly straightforward for simple situations (eg passing IDs in as strings), trying to pass a multi-line string (eg asset contents) or datatype is hard, potentially requiring detailed workarounds. Moreover, what isn't possible at present is resolving keywords or querying an API for metadata, page contents, link types, status etc (really any type of data) from within the SSJS so you can use the data to make decisions, perform processing and generate output. Here's a basic contrived example:
The second line will only resolve the keyword after being print()'d, meaning its value can't be used for in further SSJS processing or decision making.
Reported at https://squizmap.squiz.net/matrix/10541