ION Actions examples for Supply Chain
Required fields before approval
Mandate that specific PO line attributes are populated before submitting for approval
{
"enabled": true,
"title": "Purchase line items must have a need date",
"target": "PURCHASEORDERLINE",
"eventType": "UPDATE",
"ruleType": "VALIDATION",
"errorState": "ALLOW",
"context": "{ purchaseOrderLine(id: $id) { id needDate } }",
"code": "if context.get('changes', {}).get('purchaseOrderLines', {}).get('status', {}).get('new') == 'requested' and context.get('purchaseOrderLine', {}).get('needDate') is None: raise ValidationError()"
}
Mandate that specific PO header (custom) attributes are populated before submitting for approval
{
"enabled": true,
"title": "Purchase requires a justification before it can be ordered"
"target": "PURCHASEORDERLINE",
"eventType": "UPDATE",
"errorState": "ALLOW",
"context": "{ purchaseOrderLine(id: $id) { purchaseOrder {id attributes {key value}} } }",
"code": "if context.get('changes', {}).get('purchaseOrderLines', {}).get('status', {}).get('new') == 'requested' and any(attribute.get('key') == 'PO Justification' and not attribute.get('value') for attribute in context['purchaseOrderLine'].get('purchaseOrder', {}).get('attributes', [])): raise ValidationError()"
}
Purchase Approvals
We used to rely on ION Actions to enforce purchase order approval levels, but we now have a first class method to do so that is easily understandable and maintained. Check that out here.
Other Example Rules:
Receipt line items must have a location
{
"create_rule": {
"title": "Receipt line items must have a location",
"ruleType": "VALIDATION",
"eventType": "CREATE",
"target": "RECEIPTITEM",
"code": "if context.get('receiptItem', {}).get('partInventory', {}).get('locationId') is None: raise ValidationError()",
"context": "{ receiptItem(id: $id) { id partInventory{locationId} } }",
"enabled": true
}
}
Required fields for part creation
{
"create_rule": {
"title": "Required fields for part creation",
"ruleType": "VALIDATION",
"eventType": "CREATE",
"target": "PART",
"code": "if (context.get('part', {}).get('partType') == 'PART') and any([not context.get('part', {}).get('revision') == '', not context.get('part', {}).get('description') == '', not context.get('part', {}).get('trackingType') == '', not context.get('part', {}).get('sourcingStrategy') == '', not context.get('part', {}).get('unitOfMeasure') == '']): raise ValidationError()",
"context": "{ part(id: $id) { id revision revisionScheme description trackingType sourcingStrategy partType unitOfMeasure { id } attributes { key value } } }",
"enabled": false
}
}
Last updated
Was this helpful?