Working with Conversion Codes V2

The new Qmica Validation Engine uses V2 conversion codes (Rhai) instead of Legacy conversion codes.


If you currently use Legacy conversions, you must review and update them to ensure they work correctly with the new Validation Engine. Existing Legacy conversions should remain unchanged during the transition.


This guide explains how to configure, test and validate V2 conversion codes, including practical examples for common product data transformations.


Important — Conversion codes must be updated for V2

If your Qmica environment already contains Legacy conversion codes, these must be reviewed before using the new Validation Engine.


Legacy conversion codes remain in place for the existing validation functionality.


V2 conversion codes (Rhai) are used by the new Validation Engine.


Existing Legacy conversions may require rewriting because V2 uses different syntax.


Both versions can be maintained during the transition.


Do not replace or delete your Legacy conversion codes. Add the new conversion logic to the separate V2 field.

1. Open your conversion settings

  1. Navigate to the relevant attribute mapping in Qmica.
  2. Locate the attribute that uses a conversion code.
  3. Click the Conversion button to open the conversion editor.


2. Update your conversion code for V2


  1. In the Edit conversion window, select the V2 tab.
  2. Enter your Rhai-compatible conversion code in the V2 conversion field.
  3. Click Test V2 conversion.
  4. Check the Output to confirm that the conversion produces the expected result.
  5. Click Save to save the conversion.


Important: Keep the existing conversion code under the Legacy tab unchanged.


If the output is incorrect or empty, review your Rhai expression, adjust it and test again before saving.



3. Convert common Legacy expressions to Rhai

The following examples illustrate how existing conversion codes can be adapted for V2.

Purpose

V2 Conversion codes

Convert to GTIN-14

to_gtin14(value)

Date formatting

format_date( value, "dd-MM-yyyy", "yyyy-MM-ddTHH:mm:ss" );

Convert Yes/No to Boolean

to_bool(value, ["WAAR", "YES", "yes"])

Replace comma with decimal point

replace(value, ",", ".")

 

Convert CMT into MMT

let normalized = value.to_string().replace(",", ".");
let result = parse_float(normalized) * 10.0;
result

Convert GRM to KGM, rounded to two decimal places

let normalized = value.to_string().replace(",", ".");
let result = parse_float(normalized) / 1000.0;
(result * 100.0).round() / 100.0

Extracts the highest value from a range, removes the voltage unit (V), and replaces commas with decimal points.

replace(replace(value, ",", "."), " V", "").split("-")[1]

Extracts the lowest value from a range, removes the voltage unit (V), and replaces commas with decimal points.

replace(replace(value, ",", "."), " V", "").split("-")[0]

Replace comma with dot + split value:

value = value.replace(",", ".");value = value.split(" ")[0];value

Examples

Conversion

Input

Output

GTIN-14

8712836926264

08712836926264

Date

16-08-2025

2025-08-16T00:00:00

Boolean

Yes

true

Boolean

WAAR

true

Boolean

yes

true

Decimal separator

26,8

26.8

Extracts the highest value from a range, removes the voltage unit (V), and replaces commas with decimal points.

220-240 V

240

Extracts the lowest value from a range, removes the voltage unit (V), and replaces commas with decimal points.

220-240 V

220

Replace comma with dot + split value:

2,20 2,40

2.20

CMT to MMT:

12,5

125

GRM to KGM (2 decimals):

1250

1,25


4. Save and validate your conversion

  1. Save the updated V2 conversion code.
  2. Navigate to Processing → Validations.
  3. Create a validation set containing the relevant products.
  4. Run the validation using the new Validation Engine.
  5. Review the resulting values and validation issues.


If the conversion does not produce the expected result, adjust the V2 expression and run the validation again.

5. Keep Legacy and V2 conversions during the transition



Until the Legacy validation functionality is no longer required, maintain both conversion versions.


Legacy

V2 (Rhai)

Used by the previous validation functionality

Used by the new Validation Engine

Existing conversion syntax

Rhai-compatible syntax

Keep unchanged during migration

Configure and test separately


Important: A successful migration requires checking the actual output values, not just whether the new conversion code is accepted.


6. Monitor your validation set

Return to Validations to monitor progress.


When processing has completed, a green checkmark appears in the Build column.


Important: The green checkmark confirms that processing has completed. It does not mean that every product has passed validation.


Use the three-dot menu next to a validation set to access:

  • Show items — View the validation status of individual products.
  • Show issues — Review validation errors grouped by issue.
  • Revalidate — Run validation again after making corrections.