Maximo Open Forum

 View Only

 Automation script

  • Everything Maximo
John Bauer's profile image
John Bauer posted 03-25-2024 17:48

Hi,

I have an automation script where the launchPoints are Objects and I want to be able to add 2 additional launchPoints to include Attributes, DESCRIPTION and JPDURATION. Script below,

from psdi.mbo import Mbo
from psdi.mbo import MboConstants
from java.util import Date

if (mbo.isBasedOn("JOBPLAN")):
   if (mbo.isNew() and mbo.getString("STATUS") == 'DRAFT' ):
        mbo.setValue("MRP_JPMODIFYTYPE","MAJOR",11L)
   if (mbo.isModified() and not mbo.isNew() and  not mbo.isModified("MRP_JPMODIFYTYPE") and not mbo.isModified("STATUS")):
        mbo.setValue("MRP_JPMODIFYTYPE","MAJOR",11L)
   if (mbo.isNew() and mbo.isModified("MRP_JPMODIFYTYPE") and mbo.getInt("PLUSCREVNUM") > 0 ):
        mbo.setValueNull("MRP_JPMODIFYTYPE")
 
 ####################################################################################
 # JB Added 'or launchPoint =="DESCRIPTION" or launchPoint =="JPDURATION" 20240318' #
 # Changed <> 'MAJOR' to != 'MAJOR'                                                 #
 ####################################################################################
mboJP = mbo.getOwner()
if (mboJP is not None and mboJP.getString("STATUS") == 'PNDREV'):
    if(launchPoint=="JPLABOR" or launchPoint=="JPMATERIAL" or launchPoint=="JPSERVICE" or launchPoint=="JPTOOL" 
    or launchPoint =="DESCRIPTION" or launchPoint =="JPDURATION"):
        if (mboJP.isBasedOn("JOBPLAN") and not mboJP.isModified()
        and mboJP.getString("MRP_JPMODIFYTYPE") != 'MAJOR'):
            mboJP.setValue("MRP_JPMODIFYTYPE","MINOR")
            
mboJP = mbo.getOwner()
if (mboJP is not None):
    if(launchPoint=="JOBTASK"  or launchPoint=="JPASSETSPLINK" or launchPoint=="PLUSCJPDATASHEET" or launchPoint=="JOBPLANSPEC" or launchPoint=="JOBTASKSPEC" ):
        if (mboJP.isBasedOn("JOBPLAN") and not mboJP.isModified()):
            mboJP.setValue("MRP_JPMODIFYTYPE","MAJOR",mbo.NOACCESSCHECK|mbo.NOVALIDATION)

Any help would be appreciated.

Cheers

JB

Martin Fabra's profile image
Martin Fabra

Hi @John Bauer! I don't quite understand what you want to do. In your code you already include both launch points and determine what the script is going to do. What do you need to do? Add the 2 launch points?

In automation Scripts you need to "Create" Script with attribute Launch Point. Then you need to complete date, the most important is call the new launch point DESCRIPTION and JPDURATION (you need to repeat the process two times). In Script section, you need to set "Existing Script" and then you need to select your existing script that you want to add the launch point attribute.

If that is not what you need, let me know and I will be happy to help you.

Regards!

John Bauer's profile image
John Bauer

Hi Martin,

Thanks for your response. What I am trying to achieve is if the change to the revised Job Plan is task related then it is a Minor change and the work flow will allow the status to be changed to 'ACTIVE' . If there are any other changes then work flow assigns the revised Job Plan to an approval group for them to change to 'ACTIVE'. This was done at the Object level as there were too many Attribute launchpoints that needed to be included. I just want to add DESCRIPTION and JPDURATION to be included in the Minor change, but because the launchpoints are at the Object level I cannot achieve this. I was hoping that I could have added to the code to include DESCRIPTION and JPDURATION. I have attached the dump of launchpoints used.

I hope this better explains what I was hoping to achieve.

Cheers

JB

Jason VenHuizen's profile image
Jason VenHuizen

I think what you are looking for is the isModified("ATTRIBUTENAME") method on the Mbo object. So you can do something like the following to check if the DESCRIPTION or JPDURATION have been changed.

(mboJP.isModified("DESCRIPTION") or mboJP.isModified("JPDURATION"))
On a related note about adding launch points, if you use the Maximo Developer Tools extension for VS Code you can declare your launch points and it will add or remove launch points for you as required.
If you are writing a lot of automation scripts it will save you an enormous amount of time and effort and enable better development practices as well such as implement ing automated deployments.
- Jason