Saturday, April 30, 2022

Maximo Yes/No/Cancel Exception using Automation Script on Work Order Status Change

Many clients want to avoid customization and use only Automation Scripts for implementing business logic; One of the frequent request is to throw warning on Work Order status change.

The best triggering event is to have an attribute launch point on object:attribute WOCHANGESTATUS:STATUS to throw error or warning. 

code automationscripts/attributelaunchpoint/wochangestatusscript.py



Create the below items for the script to run in the environment

1. Relationship name - C_OPENINVUSE ; Parent - WPMATERIAL ; Child - INVUSELINE

(refwo=:wonum or refwo in (select wonum from workorder where parent=:wonum and siteid=:siteid)) and itemnum = :itemnum and itemsetid = :itemsetid and siteid = :siteid and invusenum in (select invusenum from invuse where siteid = :siteid and status in ('ENTERED', 'STAGED'))

2. Maximo Messages 

i) Message Key: AVOIDRECORD  Message Group: WPINVUSE 

Display Method: MSGBOX  Error

Value: Work Order Plan Materials is used in open Inventory Usage {0}

Buttons: OK ? 

ii) Message Key: CANAPPROVEWO  Message Group: WORKORDER 

Display Method: MSGBOX  Information

Value: Planned materials are not yet issued to WO from Inventory Usage {0}. Completing the work order will block the Inventory issue and retain the materials in storeroom. Would you like to proceed?

Buttons: Yes ?  No ? 

Testing:

When you try to change the status of WO to COMP and the WO has open Inventory Usage record in statuses - ENTERED and STAGED, you will get the Yes/No pop-up window.

This example doesn't include Cancel button - you can configure it in message (ii) and add a method def cancel() in the code.

References: https://www.bpdzenith.com/prompting-a-yesno-dialog-from-an-automation-script/