ION Actions examples for Runs and Procedures

All Steps Need Dependencies:

{
  "create_rule": {
    "enabled": true,
    "title": "Check if Step has dependencies",
    "target": "PROCEDURE",
    "eventType": "UPDATE",
    "ruleType": "VALIDATION",
    "errorState": "ALLOW",
    "context": "{ procedure(id: $id) { id steps{location{name} upstreamStepIds downstreamStepIds } } }",
    "code": "if (context.get('changes', {}).get('procedures', {}).get('status', {}).get('new') == 'in_review' and any([step for step in context.get('procedure', {}).get('steps', []) if not (step.get('upstreamStepIds') or step.get('downstreamStepIds'))])): raise ValidationError()"
  }
}

All Child Steps Need Dependencies:

{
  "create_rule": {
    "enabled": true,
    "title": "Check if Child Step has dependencies",
    "target": "PROCEDURE",
    "eventType": "UPDATE",
    "ruleType": "VALIDATION",
    "errorState": "ALLOW",
    "context": "{ procedure (id: $id) { id steps { location { id } title isStandardStep steps { title isStandardStep downstreamStepIds upstreamStepIds location { name } } } } }",
    "code": "if context.get('changes', {}).get('procedures', {}).get('status', {}).get('new') == 'in_review' and any([step for step in context.get('procedure', {}).get('steps', []) if 'steps' in step and len(step.get('steps', [])) > 1 and any([nested_step for nested_step in step.get('steps', []) if not nested_step.get('upstreamStepIds') and not nested_step.get('downstreamStepIds')])]): raise ValidationError()"
  }
}

All Steps Need a Location

{
  "create_rule": {
    "enabled": true,
    "title": "Check if Step has Location",
    "target": "PROCEDURE",
    "eventType": "UPDATE",
    "ruleType": "VALIDATION",
    "errorState": "ALLOW",
    "context": "{ procedure (id: $id) { id steps { location {name} title standardStepStatus steps { title standardStepStatus downstreamStepIds upstreamStepIds } } } }",
    "code": "if context.get('changes', {}).get('procedures', {}).get('status', {}).get('new') == 'in_review' and [step for step in context.get('procedure', {}).get('steps', []) if step.get('location') is None and step.get('standardStepStatus') is None]: raise ValidationError()"
  }
}

All Child Steps Need a Location

{
  "create_rule": {
    "enabled": true,
    "title": "Check if Child Step has Location",
    "target": "PROCEDURE",
    "eventType": "UPDATE",
    "ruleType": "VALIDATION",
    "errorState": "ALLOW",
    "context": "{ procedure (id: $id) { id steps { location { id } title standardStepStatus steps { title standardStepStatus downstreamStepIds upstreamStepIds location { name } } } } }",
    "code": "if context.get('changes', {}).get('procedures', {}).get('status', {}).get('new') == 'in_review' and any(nested_step for step in context.get('procedure', {}).get('steps', []) for nested_step in step.get('steps', []) if nested_step.get('standardStepStatus') is None and nested_step.get('location') is None): raise ValidationError()"
  }
}

A Procedure can only move to ‘In Review’ when the correct reviewers from the correct teams have been added:

{
  "create_rule": {
    "enabled": true,
    "title": "Procedure requires the correct teams to review",
    "target": "PROCEDURE",
    "eventType": "UPDATE",
    "ruleType": "VALIDATION",
    "errorState": "ALLOW",
    "context": "{ procedure (id: $id) { type attributes {key value} reviewRequests { id status reviewer { id teams { name } roles { name } } } } }",
    "code": "if context.get('changes', {}).get('procedures', {}).get('status', {}).get('new') == 'in_review' and [attributes for attributes in context.get('procedure',{}).get('attribute', {}) if context.get('attribute', {}).get('key') == 'Procedure Type' and context.get('attribute', {}).get('value') == 'Build'] and not (any('Responsible Engineer' in team.get('name', '') for reviewer in context.get('procedure', {}).get('reviewRequests', []) for team in reviewer.get('reviewer', {}).get('teams', [{}])) and any('Production' in team.get('name', '') for reviewer in context.get('procedure', {}).get('reviewRequests', []) for team in reviewer.get('reviewer', {}).get('teams', [{}])) and any('Mission Assurance' in team.get('name', '') for reviewer in context.get('procedure', {}).get('reviewRequests', []) for team in reviewer.get('reviewer', {}).get('teams', [{}]))): raise ValidationError()"
  }
}

Check if the custom attribute ‘Procedure Type’ is filled out

{
  "create_rule": {
    "enabled": true,
    "title": "Procedure Type must be filled out",
    "target": "PROCEDURE",
    "eventType": "UPDATE",
    "ruleType": "VALIDATION",
    "errorState": "ALLOW",
    "context": "{ procedure(id: $id) { status, attributes { key, value } } }",
    "code": "if context.get('changes', {}).get('procedures', {}).get('status', {}).get('new') == 'in_review' and any(attributes for attributes in context.get('procedure',{}).get('attributes', {}) if attributes.get('key') == 'Procedure Type' and attributes.get('value') is None): raise ValidationError()"
  }
}

Prevent a run from being completed if the aBOM isn’t filled out

{
  "create_rule": {
    "enabled": true,
    "title": "all aBOM items must be filled out to complete a run",
    "target": "RUNSTEP",
    "eventType": "UPDATE",
    "ruleType": "VALIDATION",
    "errorState": "ALLOW",
    "context": "{ runStep(id: $id) { id position status run { status partInventory { abomItems { part { partNumber description } children { part { partNumber description } partInventoryId } } } } } }",
    "code": "if context.get('runStep', {}).get('run', {}).get('status') in ['COMPLETE', 'PARTIAL_COMPLETE'] and any(child.get('partInventoryId') is None for abomItem in (context.get('runStep', {}).get('run', {}).get('partInventory', {}) or {}).get('abomItems', []) for child in abomItem.get('children', [])): raise ValidationError()"
  }
}

Last updated