Maximo Open Forum

 View Only

 Automation Script on duplicated records

  • Customizations
UNARINE MUDZUNGA's profile image
UNARINE MUDZUNGA posted 05-22-2024 15:49

Greetings, All

I have created an INIT Object Launch WorkOrder Script that Sets WorkOrder number Prefix. I had to use the script to set prefix as the WorkOrder is used across four different streams and each stream had to have a different prefix for their WorkOrders. Now the challenge is that when duplicating the WorkOrder, the script does not fire which leads to creation of WorkOrder without Prefix. Is the a way to get the script to fire when duplicating WorkOrder?


Thank You.

Regards,

Una

Stephen Hume's profile image
Stephen Hume

Hello Unarine, I might suggest you create a script called workorder.duplicate and place your code for creating the correct prefix in that script.

The .duplicate script does not need a launchpoint and will run only when a work order is duplicated.

Here is some information that also might help.
https://bportaluri.com/2019/11/maximo-scripting-controlling-mbo-duplicate.html

Hope this helps.

Alex Walter's profile image
Alex Walter

Agreed with what Stephen suggested about the WORKORDER.DUPLICATE script. You will have two implicit variables, mbo and dupmbo representing the work order you are copying and the newly created work order.

One thing I would suggest though is not to have the original script fire on the INIT Object Launch Point Event. That script fires a lot, and you really only need it to fire once on creation of a new work order. You can drop the launch point and simply name your script WORKORDER.NEW, which will fire only once on creation of a new work order.

Hope that helps,

Alex

UNARINE MUDZUNGA's profile image
UNARINE MUDZUNGA

Thank you for you response. Followed the below and created WORKORDER.DUPLICATE script, however, the script is not setting the workorder number as expected. I added a set DESCRIPTION to test if it would set it and that worked. Unfortunately it is not seeting wonum. Here's the script:

WoNum = mbo.getString("WONUM")

# Check the app:
if app == 'TTWOTRACK':
    # Get the Mbo value so that a manual autokey generation can be triggered
    wonumValue = dupmbo.getMboValue("WONUM")

    # Trigger an autokey
    wonumValue.autoKey()

    # Set autokey value for WONUM"       
    dupmbo.setValue("WONUM","TT" +WoNum)

    # Set DESCRIPTION attribute
    dupmbo.setValue("DESCRIPTION", "TESTDUPWO")

Sankar Ganesh V S's profile image
Sankar Ganesh V S

Hi, 

Did you try getting the wonum after calling autokey()?
In your code, 'WoNum = mbo.getString("WONUM")' is called before autokey() , not afterwards.

Thanks!

Sankar