Skip to content

$getSharedParam

Reads a shared parameter from any object by its logical name. Returns a full metadata object including the display value, GUID, and parameter name.


Definition

$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);

    $val :=
      $present and $exists($sp.valueAsString) and $sp.valueAsString != ""
        ? $sp.valueAsString
        : (
            $present and $exists($sp.value)
              ? $sp.value
              : "Parameter niet aanwezig"
          );

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

Dependencies

Requires two variables to be defined in the outer scope before calling this function:

$paramGuids := {
  "NLRS_C_brandwerendheid": "8fe8f5ce-4979-4679-b5e0-ccfb362b9059"
};

$paramMetaByGuid := $merge(
  $$[type = "Parameter" and values.guid in $paramGuids.*].{
    $string(values.guid): {
      "guid": values.guid,
      "name": values.name
    }
  }
);

Parameters

Parameter Type Description
$object object The element to read the parameter from (pass $ for current element)
$logicalName string The key in $paramGuids — the human-readable parameter name

Return value

{
  "paramExist": true,
  "value": "EI 60",
  "guid": "8fe8f5ce-4979-4679-b5e0-ccfb362b9059",
  "name": "NLRS_C_brandwerendheid"
}

When the parameter is absent:

{
  "paramExist": false,
  "value": "Parameter niet aanwezig",
  "guid": "8fe8f5ce-4979-4679-b5e0-ccfb362b9059",
  "name": "NLRS_C_brandwerendheid"
}

Usage

$[type = "FamilySymbol"].{
  "id": id,
  "name": name,
  "NLRS_C_brandwerendheid": $getSharedParam($, "NLRS_C_brandwerendheid")
}

Access sub-fields in the validator:

  • NLRS_C_brandwerendheid.paramExistbool:Is true
  • NLRS_C_brandwerendheid.valuelist:IsIn [...]

Used in rules

  • rule-01536396 — NLRS_C_brandwerendheid = Fire Rating
  • rule-0f6529fa — NLRS_C_brandwerendheid heeft een geldige waarde
  • And many shared parameter existence + value rules