Utils
Using Nexus utils inside the script
File Utils
Converts file data to JSON
return (FileUtils.convertFileToJSON(getMeta('files.fileNameHere')).then(json => { setCtx('jsonData', json['sheetNameHere']); }));
XML Utils
convertJSONtoXML: Converts JSON to XML.
const empXml = XMLUtils.convertJSONtoXML({ name: 'abc', age:25 });convertXMLtoJSON: Converts XML to JSON.
const empObj = XMLUtils.convertXMLtoJSON('<name>abc</name><age>25</age>');
Date Utils
format: Converts date to the required format.
Accepts 2 parameters.
Date
Format
const date = DateUtils.format(new Date('12-28-2019'), 'YYYY-DD-MM')
add: Adds the given date by the amount & unit of datetime specified.
Accepts 3 parameters.
Date
Amount
Unit of Datetime (year/years/y, month/months/M, week/weeks/w, day/days/d, hour/hours/h, minute/minutes/m, second/seconds/s, millisecond/milliseconds/ms, quarter/quarters/Q)
const date = DateUtils.add(new Date(), 1, 'day')
subtract: Substracts the given date by the amount & unit of datetime specified.
Accepts 3 parameters.
Date
Amount
Unit of Datetime (year/years/y, month/months/M, week/weeks/w, day/days/d, hour/hours/h, minute/minutes/m, second/seconds/s, millisecond/milliseconds/ms, quarter/quarters/Q)
const date = DateUtils.subtract(new Date(), 1, 'day')
isValidDate: Returns true if the date provided is valid.
const date = DateUtils.isValidDate(new Date())convertDateToISO: Converts date object to ISO.
const date = DateUtils.convertDateToISO(new Date() as any)convertISOToDate: Converts ISO to a date object.
const date = DateUtils.convertISOToDate('10/09/2020' as any)parse: Converts given string date to a date object.
Accepts 2 parameters.
Date in string
format - optional.If provided converts the date string to the provided format.
const date = DateUtils.parse('10/09/2020' as any)
Compression Utils
1. decompress: Decodes the given data.
Accepts 2 parameters.
input
inputEncoding/decompressoptions (ByteArray/Buffer/Base64/BinaryString/StorageBinaryString) - Default is Base64.
2. compress: Encodes the given data.
Accepts 2 parameters.
input
outputEncoding/compressoptions (ByteArray/Buffer/Base64/BinaryString/StorageBinaryString) - Default is Base64.
Last updated
Was this helpful?