Maximo Open Forum

 View Only
Expand all | Collapse all

Automation Script Change Status

  • 1.  Automation Script Change Status

    Posted 06-22-2022 00:40
    Hi Guys, 

    Have you ever experienced when you want to change the workorder status using a script but it doesn't work?
    I changed the status of the workorder using the changeStatus function in the script, but the only thing that changed was the status in wostatus and the status in the workorder did not change. I need to change the state on the workorder object, please help me
    #Customizations

    ------------------------------
    Alief Harry
    PT Indonesia Comnets Plus
    ------------------------------


  • 2.  RE: Automation Script Change Status

    Posted 06-22-2022 01:48
    Hi Alief,

    Why do you want to use script on workorder status change? Can you attach your Code.

    ------------------------------
    PAVAN KUMAR
    Maximo Consultant
    ------------------------------



  • 3.  RE: Automation Script Change Status

    Posted 06-22-2022 22:36
    Hi Pavan,

    I use script for change status in workorder, because there is a need in the calculation, if the calculation has a value then the status will change. For example, the script that I show,
    1. if followupCreated is 1 or 2 then the status changes to WFOLLOWUP
    2. if followupCreated is 0 then the status changes to COMP
    3. if followupCreated is 3 then the status changes to WOREJECT

    Thank you.
    Change status with automation script


    ------------------------------
    Alief Harry
    PT Indonesia Comnets Plus
    ------------------------------



  • 4.  RE: Automation Script Change Status

    Posted 06-22-2022 10:52
    What was your launch point for the automation script to change the status? And were you providing any of the MboConstants to suppress logic?

    Some launch points, such as actions, don't explicitly save. And the changeStatus action doesn't call a save. The dialog triggers a save before and after and in the processes where we make status changes in the background we're explicitly calling a save. I wouldn't have expected the status entry to be committed but I'd have to look at the code to see how that's handled.

    ------------------------------
    Steven Shull
    IBM
    ------------------------------



  • 5.  RE: Automation Script Change Status

    Posted 06-22-2022 18:46
    I agree with Steve, more info is needed.  If the launch point is post commit, then the work order would already be saved and won't save again if you change the status at this point.

    ------------------------------
    Steven Hauptman
    IBM
    ------------------------------



  • 6.  RE: Automation Script Change Status

    Posted 06-22-2022 22:40
    Hi Steven, 

    My launch point for automation script is ACTION and this object is WORKORDER, yes I use MboConstants for changeStatus.
    I will show my script, here is my script :
    Change status with automation script

    Thank you.

    ------------------------------
    Alief Harry
    PT Indonesia Comnets Plus
    ------------------------------



  • 7.  RE: Automation Script Change Status

    Posted 06-23-2022 11:33
    How is this action being called? I've tested escalation & a UI push button with similar code to yours and it works in my 7.6.1.2 environment.

    My guess is that there is another save occurring before this code fires. If that's the case saving the set a second time won't work and would explain why the WORKORDER record itself isn't updating. As an example, I added a save at the beginning of my script and left the one at the end after the status change. I made a change to the record (updated the description) and called my action. In that scenario the description is saved, the status history is recorded, but the work order is not updated.

    I wouldn't personally use the 9L (suppressing action & validation) but I tested the script with it and it also worked in my environment. The reason I don't like suppressing action and validation is it either does nothing (which makes it pointless to have) or it does something bad (suppresses validation) that you really don't want to occur on a status change. I tested a few scenarios (going back from COMP->INPRG, having a condition on the status that would make it not valid, etc.) and the errors are still thrown so I'm assuming this is mostly at least a case of it not doing anything.

    ------------------------------
    Steven Shull
    IBM
    ------------------------------



  • 8.  RE: Automation Script Change Status

    Posted 11-02-2023 21:12

    Hello All,

    We too are having the same issue and am wondering if there is a way out.

    The automatically approve labor transaction on the Organization option is set to false.

    Now we want to CLOSE the work order. If there are unapproved labor transactions, Maximo will not allow the WO to be closed.

    So we have 2 actions. First is an automation script to approve the labor and the second is an action to change status to CLOSE. The same thing is happening for us. The labor transaction is getting approved, there is a status history record in the WOSTATUS table, but the work order does not update the status field to CLOSE.

    In the automation script, we are calling the Labtrans save method after setting the GENAPPRSERVRECEIPT flag to1. The log shows that the work order is saved at this point in time (but the status field is not modified as we have still not invoked the second action to change status to CLOSE), the WOSTATUS is added with the CLOSE status and the LABTRANS is updated with the approval flag.

    When the second action to change the WO status is invoked, nothing is happening. Could it because the work order was already saved as per above?

    How can this be overcome? Any suggestions would be appreciated.

    Regards,

    Priyaranjandas



    ------------------------------
    Priyaranjandas Kolambkar
    Kuwait Oil Company
    ------------------------------



  • 9.  RE: Automation Script Change Status

    Posted 06-23-2022 08:57

    Hello Alief!

    I have encountered occasional challenges using mbo.getThisMboSet().save() (similar to you).  I would recommend that--since this script is invoked via an action and is likely (almost?) always a result of a direct user choice w/in the application, that you leverage the appbean to save...

    The applicable code would be:
    session = service.webclientsession(); ## get the current session
    appbean = session.getCurrentApp().getAppBean(); ## get the appbean
    appbean.SAVE(); ## save

    ​​​

    ------------------------------
    Jade Warren
    Great River Energy
    ------------------------------



  • 10.  RE: Automation Script Change Status

    Posted 06-27-2022 23:09
    Hello Jade,

    I tried your code, but it doesn't give any change the result is still the same doesn't want to change the state on the workorder and only changes in the wostatus object.
    I've tried to force change with the query but it just doesn't work, am I missing something? thanks

    ------------------------------
    Alief Harry
    PT Indonesia Comnets Plus
    ------------------------------



  • 11.  RE: Automation Script Change Status

    Posted 06-13-2023 08:40
    Edited by Phil Runion 06-13-2023 08:40

    Inspired by this thread I put together a few thoughts on using MBO Constants with automation scripts. If you want to read more I have included a link below. 

    https://www.projetech.com/maximo-blog/maximo-automation-scripts-overwriting-maximo-business-logic-with-mboconstants



    ------------------------------
    Phil Runion
    Projetech
    ------------------------------