Maximo Open Forum

 View Only
  • 1.  Automation Script Change Status

    Posted 8 days ago
    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

    Maximo Certified
    Posted 8 days ago
    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 7 days ago
    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

    Maximo Certified
    Posted 8 days ago
    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 7 days ago
    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 7 days ago
    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

    Maximo Certified
    Posted 7 days ago
    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 7 days ago

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



  • 9.  RE: Automation Script Change Status

    Posted 2 days ago
    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
    ------------------------------