CompanionCompanion
Companion for Delivery
Companion for Business
Companion for Integration
Contact us
Companion for Delivery
Companion for Business
Companion for Integration
Contact us
  • Companion for Integration

    • Introduction
    • Getting Started
    • Configuration
    • Excel templating
    • How it works
  • YAML Configuration

    • Principles
    • Syntax
    • Validation
  • Custom Functions

    • Summary
    • arrayToJSON
    • bool
    • concatValueAndUnit
    • convertUnit
    • currentContextId
    • exportTime
    • eval
    • firstNonEmpty
    • getContextName
    • getEvents
    • getLastEventTime
    • getReferencesByAttributeGroup
    • getStoredValue
    • getWorkspaceId
    • hash
    • hasStoreKey
    • if
    • integer
    • join
    • mergeInheritedValues
    • multiValuesToJSON
    • number
    • nodeList
    • order
    • resolveUnitLabel
    • serializeAssetPushLocationsToJSON
    • serializeAttributeLinksToJSON
    • serializeContextReferenceToJSON
    • serializeContextReferencesToJSON
    • serializeContextValuesToJSON
    • serializeDataContainerToJSON
    • serializeDataContainersToJSON
    • serializeListOfValueValuesToJSON
    • serializeReferencesToJSON
    • serializeReferenceToJSON
    • serializeValuesToJSON
    • store
    • toXML
    • uppercase
  • Execution

    • Summary
    • Composite
    • From STEP
    • Standalone
    • Performance statistics
  • Configuration

    • ActiveMQ extension
    • Amazon AWS extension (SNS, SQS, Kinesis, S3)
    • ElasticSearch/OpenSearch extension
    • File extension (Excel, CSV, JSON, XML, JSONL, XMLL)
    • Kafka extension
    • Kafka Core extension
    • MongoDB/Cosmos DB extension
    • SQL extension
    • REST extension
    • Google Pub/Sub extension
  • c4i SaaS

    • Introduction
    • Managing jobs
    • Managing executions
    • Managing users
    • Changelog
  • Changelog

    • Core features changelog
    • ActiveMQ extension changelog
    • Amazon AWS extension changelog
    • Composite extension changelog
    • ElasticSearch extension changelog
    • File extension changelog
    • Kafka extension changelog
    • Kafka Core extension changelog
    • MongoDB/Cosmos DB extension changelog
    • SQL extension changelog
    • REST extension changelog
    • Google Pub/Sub extension changelog

multiValuesToJSON

The multiValuesToJSON function is used to serialize a single multivalued attribute to a JSON array.

Syntax

c4i:multivaluesToJSON(xpath [, lov] [, units] [, values])

Parameters

xpath

XPath to a "MultiValue" node

lov (optional)

  • Indicates how to represent LOV values
  • The authorized values are "DISPLAY_LOV_VALUE_LABEL" (default), "DISPLAY_LOV_VALUE_ID" or "DISPLAY_BOTH"

units (optional)

  • Indicates how to represent units
  • The authorized values are "NO_UNITS" (default), "DISPLAY_UNIT_ID", "DISPLAY_UNIT_LABEL"

values (optional)

  • Indicates if values and units should be concatenated or separated
  • The authorized values are "CONCAT_VALUE_UNIT" (default) or "ISOLATE_VALUE"

Return value

A JSON array containing the attribute values.

Jsdoc

The return type to use in scripts is MultiValue.

When using parameter values = "ISOLATE_VALUE", the individual values of the returned array will be of type UnitValue.

When using parameter lov = "DISPLAY_BOTH", the individual values corresponding to LOV based attributes with value-IDs will be of type LovSingleValue.

Example

Given the following STEP XML:

<STEP-ProductInformation>
    <UnitList>
        <Unit ID="unece.unit.KTM">
            <Name>km</Name>
        </Unit>
    </UnitList>
    <AttributeList>
        <Attribute ID="ATT2">
            <Validation BaseType="number">
                <UnitLink UnitID="unece.unit.KTM"/>
            </Validation>
        </Attribute>
    </AttributeList>
    <Products>
        <Product ID="PRD1">
            <Values>
                <MultiValue AttributeID="ATT1">
                    <Value ID="VAL_1">Value 1</Value> 
                    <Value ID="VAL_2">Value 2</Value> 
                </MultiValue>
                <MultiValue AttributeID="ATT2">
                    <Value UnitID="unece.unit.KTM">16</Value>
                    <Value UnitID="unece.unit.KTM">12</Value>
                </MultiValue>
            </Values>
        </Product>
    </Products>
</STEP-ProductInformation>

The following YAML configurations will produce the following output

YAML ConfigurationJSON output
c4i:multiValuesToJSON(Values/MultiValue[@AttributeID="ATT1"], "DISPLAY_LOV_VALUE_LABEL", "NO_UNITS", "CONCAT_VALUE_UNIT")["Value 1", "Value 2"]
c4i:multiValuesToJSON(Values/MultiValue[@AttributeID="ATT1"], "DISPLAY_LOV_VALUE_LABEL", "NO_UNITS", "ISOLATE_VALUE")[{"value" : "Value 1"}, {"value" : "Value 2"}]
c4i:multiValuesToJSON(Values/MultiValue[@AttributeID="ATT1"], "DISPLAY_LOV_VALUE_ID", "NO_UNITS", "CONCAT_VALUE_UNIT")["VAL_1", "VAL_2"]
c4i:multiValuesToJSON(Values/MultiValue[@AttributeID="ATT1"], "DISPLAY_LOV_VALUE_ID", "NO_UNITS", "ISOLATE_VALUE")[{"value" : "VAL_1"}, {"value" : "VAL_2"}]
c4i:multiValuesToJSON(Values/MultiValue[@AttributeID="ATT1"], "DISPLAY_BOTH")[{"id" : "VAL_1", "label": "Value 1"}, {"id" : "VAL_2", "label": "Value 2"}]
c4i:multiValuesToJSON(Values/MultiValue[@AttributeID="ATT2"], "DISPLAY_LOV_VALUE_LABEL", "NO_UNITS", "CONCAT_VALUE_UNIT")[16, 12]
c4i:multiValuesToJSON(Values/MultiValue[@AttributeID="ATT2"], "DISPLAY_LOV_VALUE_LABEL", "NO_UNITS", "ISOLATE_VALUE")[{"value": 16}, {"value": 12}]
c4i:multiValuesToJSON(Values/MultiValue[@AttributeID="ATT2"], "DISPLAY_LOV_VALUE_LABEL", "DISPLAY_UNIT_ID", "CONCAT_VALUE_UNIT")["16 unece.unit.KTM", "12 unece.unit.KTM"]
c4i:multiValuesToJSON(Values/MultiValue[@AttributeID="ATT2"], "DISPLAY_LOV_VALUE_LABEL", "DISPLAY_UNIT_ID", "ISOLATE_VALUE")[{"value":16, "unit":"unece.unit.KTM"}, {"value":12, "unit":"unece.unit.KTM"}]
c4i:multiValuesToJSON(Values/MultiValue[@AttributeID="ATT2"], "DISPLAY_LOV_VALUE_LABEL", "DISPLAY_UNIT_LABEL", "CONCAT_VALUE_UNIT")["16 km", "12 km"]
c4i:multiValuesToJSON(Values/MultiValue[@AttributeID="ATT2"], "DISPLAY_LOV_VALUE_LABEL", "DISPLAY_UNIT_LABEL", "ISOLATE_VALUE")[{"value":16, "unit": "km"}, {"value":12, "unit":"km"}]
Last Updated: 4/13/26, 10:42 AM
Prev
mergeInheritedValues
Next
number