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.

LOOK HERE FOR AN UPDATED ION ACTIONS EXPERIENCE

It helps you accomplish everything laid out below but with a in line code editor and streamline UI.

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:

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

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:

  • 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

Variables:

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

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).

Query variables:

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

Enabling/Disabling a rule through GraphQL

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. Query the rule to retrieve its id and _etag value

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

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

Example: Deleting an ION Action

Query variables:

Last updated

Was this helpful?