Attribute Examples

Current Status: Available in Customers Sandbox Environments

Controlling Attribute Population at Creation

This powerful use case allows you to enforce attribute assignment rules precisely at the creation event, ensuring correct attribute values before the inventory moves further through your workflow, preventing potential discrepancies with subsequent stakeholders.

  • Control custom attribute population on run creation for BUILD procedures (example attribute key ‘Pedigree’):

mutation {
  createRule(input: {
    title: "Must Have Pedigree Populated at Run Creation",
    target: RUN,
    ruleType: VALIDATION,
    eventType: CREATE,
    enabled: true,
    context: "{\n  run(id: $id) {\n    attributes {\n      key\n      value\n    }\n    procedure {\n      type\n    }\n  }\n}",
    code: "run = context.get('run', {})\nproc_type = ((run.get('procedure') or {}).get('type') or '').upper()\n\nif proc_type == 'BUILD':\n    pedigree_val = next(\n        (a.get('value') for a in run.get('attributes', [])\n          if a.get('key') == 'Pedigree'),\n        None,                    # use None as the default\n    )\n\n    # Missing if it’s None **or** empty/whitespace\n    if pedigree_val is None or not str(pedigree_val).strip():\n        raise ValidationError()\n\n\n\n",
    errorState: BLOCK
  }) {
    rule {
      id
    }
  }
}
  • Verify inventory attribute population by referencing part attributes:

This example checks attributes at the part level to ensure that the inventory instance about to be created is allowed to have the assigned attribute value. In the scenario below, the inventory attribute ‘Pedigree’ cannot be set to ‘Flight’ unless the part-level attribute ‘Flight Worthy’ is marked as ‘Yes’. This rule includes exit paths if the procedure does not exist or is not of type ‘BUILD’.

Last updated

Was this helpful?