Skip to content

Functions

/* Get shared parameter values (with optional boolean normalization) */
$getSharedParam := function($object, $logicalName){
(
    $guid := $lookup($paramGuids, $logicalName);
    $meta := $guid ? $lookup($paramMetaByGuid, $string($guid)) : undefined;
    $sp   :=
        $guid and $exists($object.values)
        ? $lookup($object.values, "p_" & $guid)
        : undefined;

    $present := $exists($sp);

    /* Raw value (string-first, fallback to value) */
    $rawValue :=
        $present and $exists($sp.valueAsString) and $sp.valueAsString != ""
        ? $sp.valueAsString
        : (
            $present and $exists($sp.value)
                ? $sp.value
                : null
            );

    /* Normalized boolean (only if recognizable) */
    $boolValue :=
        $present and $rawValue != null
        ? (
            $lowercase($string($rawValue)) in ["ja","yes","true","1"]
                ? true
                : (
                    $lowercase($string($rawValue)) in ["nee","no","false","0"]
                    ? false
                    : null
                )
            )
        : null;

    {
        "paramExist": $present,
        "value": $rawValue,
        "boolValue": $boolValue,
        "guid":  $meta ? $meta.guid : $guid,
        "name":  $meta ? $meta.name : $logicalName
    }
    )
};