ION Factory OS
  • Welcome to ION
  • Features
    • Procedures
      • Steps
        • Content
        • Datagrid
        • Fields
        • Attributes
      • Dependencies
      • Part-Procedure Relationship
      • Attributes
      • Standard Steps
      • Installation Requirements (Beta)
      • Nested Steps and Nested Standard Steps
      • Procedure Best Practices
    • Runs
      • Run Execution Overview
      • Runs And Step States
      • Batching Runs
        • Batching 2.0 Changes
      • Workcenter execution
      • Split Inventory on a Run
      • Redlines
      • Export run data
      • Scheduling runs
      • Time Tracking
      • Attributes
      • Outside Processing
      • Runs Best Practices
    • Parts Library
      • As-built Bill of Materials (aBOM)
        • Editing aBOM build requirements
        • aBOM Beta Changes
          • aBOM actions for developers
      • Inventory
        • Inventory status
        • Inventory splitting
        • Inventory merging
        • Inventory scrapping
        • Kitting
        • Inventory Movement Automations
      • Manufacturing bill of materials (mBOM)
        • mBOM versions
        • Made on Assembly (MOA)
        • Part Substitutes
        • Reference designators
      • Part Attributes
      • Part revision interchangeability
      • Supplier Part Numbers & Purchase Unit Conversions
    • Kitting and Inventory Fulfilment
      • Kit Statuses and Workflows
      • Inventory requests
      • Kitting and runs
      • Fulfilling Multiple Kits
      • Kanban Kitting
    • Purchasing
      • Purchase Orders
        • Types of Purchases
        • Purchase Order Approvals
        • Purchase Order FAQs
        • Supplier Part Numbers & Unit Conversions
        • PO Requirements, Terms, and Quality Clauses
      • Receiving/Inspection
      • Outside Processing
      • Consigned Parts
    • Barcode Labels
      • Templating
        • ION barcode minimum sizes
        • Sample templates
      • Printing
        • Configuring Zebra Browser Print
        • Server Based Barcode Printing (PrintNode)
      • Scanning
        • Scan barcodes from other systems
    • Quality
      • Issues
      • Further Actions - CAPA
      • Issues States, Dispositions, and Resolutions
      • Quality Best Practices
    • Tools
    • Locations
    • Attributes
    • Labels
      • Deleting labels
    • Notifications
    • Search
    • Settings
      • Role based access control
        • Full Glossary of ION Permissions
    • ION Actions
      • ION Actions examples for Quality
      • ION Actions examples for Runs and Procedures
      • ION ACTIONS examples for Supply Chain
  • Analytics
    • Inventory valuation
    • Part impact analysis
    • Users, Roles, Teams
    • Analytics FAQ
    • Data Connector
    • Data Products
  • Plans and Autoplan
    • Autoplan
    • Autoplan glossary
    • Preparing to use Autoplan
    • Clear to build reporting
    • Running Autoplan on a schedule
    • Firm and blocked plan items
    • Location constraints
    • Autoplan suggested suppliers and procedures
    • Reorder point
    • Plan input serial numbers
    • Applying a calendar
    • Plan Reservations
    • Independent schedules
    • Drive demand from kits
    • Drive demand below buy parts configuration
    • Group plan items with the same date
    • Manualy Changing Autoplan Status
  • API
    • How to create an App with ION
    • Access Tokens
    • About GraphQL
    • Interactive API explorer
    • API Keys
    • Examples
      • Notifications
      • Runs
      • Automatically updating fields in runs
      • Parts and Part Revisioning
      • mBOMs
      • Part Inventory and Kitting
      • aBOM (As-built Bill of Materials)
      • Edit time-tracking session data
    • Changelog
    • Webhooks
    • Pagination
  • Automations
    • Auto-checkout of Run Steps
    • Auto-Consumption of Lineside Inventory
    • Automatically Send Purchases to Suppliers
    • Set Close by Run Step on Issue Creation
    • Intent Management / Grade / Tier / Pedigree
      • Data Imprinting
      • ION Actions for Intent
    • Auto-Update mBOM Revision on Part Revision Update
    • Auto-approve part-procedure relationships
    • Purchase Order PDF and Versions
    • Auto Populate PO Line Attributes
    • Imprint Attributes from One Object to Another on a Desired Event
  • Integrations
    • Deploying Integrations and Automations
    • Arena
    • Cofactr
    • Datum
    • Duro
    • NetSuite
      • Purchasing in NetSuite, Receiving in ION
      • Work Order/Assembly Builds
    • Procurable
    • PDF Generator
    • Quickbooks
    • Ramp
    • Silkline Integration
    • Slack
    • Smartsheet
    • SOLIDWORKS
    • Teamcenter
  • Training
    • Standard Operating Procedures
      • Cycle Counting
      • Tool Utilization
    • Guided Flows
    • ION Sandbox
    • Chat Support for ION
  • Troubleshooting
    • Resetting your password
    • Resetting your Multi-Factor Authentication
    • You have no roles... error
  • Changelog
  • Adminstration
    • Security
      • Backups and Security FAQ
      • Single Sign-On (SSO)
        • Okta SAML connection setup
      • Export Control
      • Report Generator Disclaimer
    • Browser and Device Compatibility
    • Authentication
      • My company is new to ION, logging in for the first time.
      • I'm told I'm not authorized to access the application
      • My account has been deactivated
    • Login Page
  • Tickets Portal
Powered by GitBook
On this page
  • 1. Introduction
  • 2. Turn rules on in your environment
  • 3. Definition of ION Action Attributes
  • 4. Creating an ION Action with GraphQL
  • 5. Updating an ION Action with GraphQL
  • 6. Deleting an ION Action with GraphQL

Was this helpful?

  1. Features

ION Actions

ION Actions is a powerful tool that allows users to create, write, update, and delete rules governing the behavior of your manufacturing processes using GraphQL.

1. Introduction

Control workflows (e.g. when users can progress status), set conditions for data validation (e.g. require fields).

2. Turn rules on in your environment

First, rules must be enabled in your organization settings in order to use them.

Check that the rules are enabled with the below query:

{
  me {
    organization {
      id
      _etag
      settings {
        rules {
          enabled
        }
      }
    }
  }
}

If they are not, enable them with this mutation:

mutation UpdateOrganization($input: UpdateOrganizationInput!) {
  updateOrganization(input: $input) {
    organization {
      settings {
        rules {
          enabled
          errorState
          errorStateMessage
        }
      }
    }
  }
}

With the following input variables (retrieve the etag from the first query):

{
  "input": {
    "id": <populate from first query>,
    "etag": "<populate from first query>",
    "settings": {
      "rules": {
        "enabled": true
      }
    }
  }
}

3. Definition of ION Action Attributes

Here are the definitions of key ION Action attributes:

  • Title: The title is a visual identifier for the ION Action, shown in toast notifications, and used for internal tracking and logging. It should briefly describe the purpose of the ION Action.

  • Context: The context is a placeholder that contains the data used in the ION Action's code. It can include model attributes, user roles, issue details, or any other relevant data. It is represented as a JSON string in GraphQL input. An example of a context structure could be:

{
    'changes': {
        'entities': {},
        'issues': {}
    },
    'currentUser': {
        'email': 'alex@firstresonance.io',
        'roles': ['user', 'admin'],
        'teams': []
    },
    'issue': {
        'approvalRequests': {},
        'approvals': {},
        'attributes': [
            {'key': 'Cause Code', 'value': None },
            {'key': 'Component Part', 'value': None },
            {'key': 'Defect Type', 'value': None },
            {'key': 'Department', 'value': None },
            {'key': 'Major Subsystem', 'value': None }
        ],
        'causeCondition': ""
    }
}
  • Code: The code attribute contains the Python-based script that is executed when the ION Action is triggered. It specifies the conditions and actions of the ION Action. If the conditions are not met, a ValidationError is raised.

  • ErrorState: All active rules will BLOCK the action from occurring if the rule conditions are met. The errorState is a deprecated feature for now, so "ALLOW" or "BLOCK" as an error state are both going to BLOCK the action upon execution of the rule.

4. Creating an ION Action with GraphQL

Create an ION Action

mutation CreateRule($create_rule: CreateRuleInput!) {
  createRule(input: $create_rule) {
    rule {
      id
      enabled
      status
      title
      target
      eventType
      context
      code
      errorState
      _etag
    }
  }
}

Variables:

{
  "create_rule": {
    "enabled": true,
    "title": "This is the message that shows in the toast banner",
    "target": "ISSUE",
    "eventType": "UPDATE",
    "ruleType": "VALIDATION",
    "errorState": "ALLOW",
    "context": "specify the fields for the code to interpret",
    "code": "the python code which runs the logic - must be a single line! (chatGPT helps a lot here)"
  }
}

5. Updating an ION Action with GraphQL

Find the rule you seek to update You'll need the rule's id and _etag value for the next step

Query all rules

{
  rules{
    edges{
      node{
        id
        _etag
        title
        ruleType
        eventType
        target
        code
        context
        enabled
      }
    }
  }
}

Write the UpdateRule Mutation:

Write a mutation using the UpdateRule input type, specifying the rule's id, _etag and the updates you seek to make (generally the context, code, or enabled values).

mutation UpdateRule($update_rule: UpdateRuleInput!) {
  updateRule(input: $update_rule) {
    rule {
      id
      _etag
      enabled
      title
      context
      code
    }
  }
}

Query variables:

{
  "update_rule": {
    "id": from step 1,
    "etag": "copied from the step 1",
    "enabled": "true or false"
    "title": "You could modify the title here, or remove this line",
    "context": "overwrite the query, or remove this line",
    "code": "completely overwrite the code, or remove this line"
  }
}

Execute the Mutation: Run the mutation in the GraphQL Explorer to update the ION Action.

NOTE: Every time you update a rule, its _etag value will change, so you need to start from step 1 each time you update a rule.

Example - Video Walkthrough

6. Deleting an ION Action with GraphQL

This isn't necessary as you can set enabled to "false", but to delete an existing ION Action:

  1. Write the DeleteRule Mutation: Write a mutation using the DeleteRule mutation, specifying the ION Action id and _etag value.

  2. Execute the Mutation: Run the mutation in the GraphQL Explorer to delete the ION Action.

Example: Deleting an ION Action

mutation DeleteRule($id: ID!, $etag: String!) {
  deleteRule(id: $id, etag: $etag) {
    id
  }
}

Query variables:

{
  "id": <ION_Action_id>,
  "etag": "<current_etag_value>"
}

PreviousFull Glossary of ION PermissionsNextION Actions examples for Quality

Last updated 8 months ago

Was this helpful?

to retrieve its id and _etag value

Query the rule
Enabling/Disabling a rule through GraphQL