General structure of a transformation code

Transformation codes are small code snippets that can be embedded in various areas to enable more complex data processing. These can be conversions of data records for displaying evaluations, exports, imports, and interface responses.

With a few exceptions, the core is always a JavaScript function called transform which contains the dataset to be transformed as its first parameter. The corresponding data structure is explained in the respective sections. Where relevant, further parameters such as the filename are also provided.

/**

  • @param {string} data
  • @param {string} filename
  • @param {object} extra
  • @returns {array}
    */
function transform (data, filename, extra) {
  return []
}

Included Libraries
Additionally, various external tools are integrated and can be used in the transformation codes:

Example for using the included libraries

An Axios example for transferring two measurement data points via HTTP to a Labordatenbank import interface:

const axios = require('axios')   // already included when calling the transform function
axios({
    method: 'post',
    url: 'https://user:pwd@labordatenbank.com/demo/imports/import/x/0/https',
    data: [ { "pH-Wert": 7.4 },
            { "LF": 1200 } ]
  }).then(function (response) {
    console.log("Response from import interface: " + response.data.msg);
});

A day.js example for date conversions:

const dayjs = require('dayjs')   // already included when calling the transform function

// Create dayjs Object from Unix timestamp
let production_date = dayjs.unix(1637762955)
console.log("Production date: " + production_date.format('DD.MM.YYYY'));

let expiration = production_date.add(2, 'year')
console.log("Expiration date: " + expiration.format('DD.MM.YYYY'));

An SFTP example:

async function transform(data) {
  const client = new SFTPClient()

  try {
    await client.connect({
      host: 'test.rebex.net',
      username: 'demo',
      password: 'password',
    })

    console.log('Connection successful!')

    // The input string must be transformed using Buffer.from as the first parameter. This is the data that will be written to the uploaded file.
    // upload_filename.txt is an example filename. Any filename is required to upload the data in the 1st parameter.
    await client.put(Buffer.from('Example Input String'), 'upload_filename.txt')
  } catch (e) {
    console.error('SFTP Error', e.message)
  }
}

Continue with: Transformation code for evaluations

Last change: 26.08.2025

Allgemeines

Einführungsphase

Auswertungen

Mitarbeiter

Aufträge

Proben

Probenvorlage

Berichte

Kunden

Berichtstabellen Editor

Kundenzone (optional)

Anlagen

Angebote

Rechnungen

Parameter

Rechnen mit Parametern

Schnittstellen

Webservice

Transformationscode

Prüfpläne / Grenzwerte / Spezifikationen

Dokumentenlenkung

Fragen und Antworten

Prüfmittel

Material

Mitarbeiterschulungen

8D-Report

Sonstiges

PDF-Vorlagen

Lieferantenbewertung

Dateiverwaltung

Prozesse