Hey Jason
I appreciate your support and the references.
I got 2 attribute launch points set up on the field PAYBYPCARD.
One is an initialize launchpoint and the other is a run.
The initialize is throwing an error on creation of a new workorder.
Everything works great when editing an existing workorder
Any ideas you have would be greatly appreciated.



from psdi.mbo import MboConstants
def main():
# If this is called in the context of a work order Mbo save and the PAYBYPCARD field is true, then make the additional fields required.
if 'mbo' in globals() and mbo.isBasedOn("WORKORDER") and mbo.getBoolean("PAYBYPCARD"):
mbo.setFieldFlag("PCARDAMOUMT",MboConstants.REQUIRED, True)
mbo.setFieldFlag("PCARDHOLDER",MboConstants.REQUIRED, True)
mbo.setFieldFlag("PCARDPAIDDATE",MboConstants.REQUIRED, True)
mbo.setFieldFlag("GLACCOUNT",MboConstants.REQUIRED, False)
else:
mbo.setFieldFlag("PCARDAMOUMT",MboConstants.REQUIRED, False)
mbo.setFieldFlag("PCARDHOLDER",MboConstants.REQUIRED, False)
mbo.setFieldFlag("PCARDPAIDDATE",MboConstants.REQUIRED, False)
mbo.setFieldFlag("ARIBAORDERNUM",MboConstants.REQUIRED, False)
mbo.setFieldFlag("OBLIGATIONNUM",MboConstants.REQUIRED, False)
main()
scriptConfig="""{
"autoscript": "WORKORDER.SAVE",
"description": "Make additional fields required if a p-card is used.",
"version": "",
"active": true,
"logLevel": "ERROR",
"scriptLaunchPoints": [
{
"launchPointName": "WORKORDER.PAYBYPCARD.INIT",
"launchPointType": "ATTRIBUTE",
"active": true,
"description": "Evaluate if additional fields should be required on initialization",
"objectName": "WORKORDER",
"attributeName": "PAYBYPCARD",
"initializeValue": true
} ,
{
"launchPointName": "WORKORDER.PAYBYPCARD.ACTION",
"launchPointType": "ATTRIBUTE",
"active": true,
"description": "Evaluate if additional fields should be required when PAYBYPCARD is checked or unchecked",
"objectName": "WORKORDER",
"attributeName": "PAYBYPCARD",
"runAction": true
}
]
}"""
Thanks
Original Message:
Sent: 11/19/2024 10:55:00 AM
From: Jason VenHuizen
Subject: RE: Need Autoscript help
Paul,
It seems that you might be missing some foundational concepts of automation scripts and launch points. I recommend that you reach out to one of the Maximo integrators for more formal assistance in this regard.
The IBM documentation is a good place to start, but you may still want to engage an expert for a more in depth explanation and assistance.
Here is a good reference to start in the interim.
https://ibm-maximo-dev.github.io/maximo-autoscript-documentation
Regards,
Jason
------------------------------
Jason VenHuizen
Sharptree
https://sharptree.io
https://opqo.io
------------------------------
Original Message:
Sent: Tue November 19, 2024 10:23 AM
From: Paul Bishop
Subject: Need Autoscript help
I don't see an option for adding a launchpoint. I see where I can activate/deactivate a launchpoint, but not how to add more than one.


------------------------------
Paul Bishop
Original Message:
Sent: Tue November 19, 2024 10:12 AM
From: Jason VenHuizen
Subject: Need Autoscript help
You will need two Attribute launch points, one on PAYBYPCARD Initialize and one on PAYBYPCARD on Run Action. Your launch point is currently on before save.
------------------------------
Jason VenHuizen
Sharptree
https://sharptree.io
https://opqo.io
Original Message:
Sent: Tue November 19, 2024 10:06 AM
From: Paul Bishop
Subject: Need Autoscript help
I appreciate the help.
This is where I am at right now.
It is not erroring, but it is also not doing anything. When I check the box and click save, it just saves and moves on with the required fields not filled in.
Note, that I had provided you an invalid field name, so I updated the script to the correct field name
This is the script:
from psdi.mbo import MboConstants
def main():
# If this is called in the context of a work order Mbo save and the PAYBYPCARD field is true, then make the additional fields required.
if 'mbo' in globals() and mbo.isBasedOn("WORKORDER") and mbo.getBoolean("PAYBYPCARD"):
mbo.setFieldFlag("PCARDAMOUMT",MboConstants.REQUIRED, True)
mbo.setFieldFlag("PCARDHOLDER",MboConstants.REQUIRED, True)
mbo.setFieldFlag("PCARDPAIDDATE",MboConstants.REQUIRED, True)
else:
mbo.setFieldFlag("PCARDAMOUMT",MboConstants.REQUIRED, False)
mbo.setFieldFlag("PCARDHOLDER",MboConstants.REQUIRED, False)
mbo.setFieldFlag("PCARDPAIDDATE",MboConstants.REQUIRED, False)
main()
scriptConfig="""{
"autoscript": "WORKORDER.SAVE",
"description": "Make additional fields required if a p-card is used.",
"version": "",
"active": true,
"logLevel": "ERROR",
"scriptLaunchPoints": [
{
"launchPointName": "WORKORDER.PAYBYPCARD.INIT",
"launchPointType": "ATTRIBUTE",
"active": true,
"description": "Evaluate if additional fields should be required on initialization",
"objectName": "WORKORDER",
"attributeName": "PAYBYPCARD",
"initializeValue": true
} ,
{
"launchPointName": "WORKORDER.PAYBYPCARD.ACTION",
"launchPointType": "ATTRIBUTE",
"active": true,
"description": "Evaluate if additional fields should be required when PAYBYPCARD is checked or unchecked",
"objectName": "WORKORDER",
"attributeName": "PAYBYPCARD",
"runAction": true
}
]
}"""
Setup

Launch Point


------------------------------
Paul Bishop
Original Message:
Sent: Tue November 19, 2024 09:35 AM
From: Jason VenHuizen
Subject: Need Autoscript help
Hi Paul,
Without seeing what you are seeing, it is hard to guess what is wrong. Based your initial example I wrong this in jython and your error about semicolons and formatting errors, perhaps you have selected Javascript / Nashorn.
If you are using Jython, be aware that spaces are significant and copy / pasting from these discussion forums can mess with the formatting. For reference here is a screenshot of the code in the Maximo editor.
Regards,
Jason
------------------------------
Jason VenHuizen
Sharptree
https://sharptree.io
https://opqo.io
Original Message:
Sent: Tue November 19, 2024 09:22 AM
From: Paul Bishop
Subject: Need Autoscript help
The first red x says Missing ";" beforer statement
The second Red x says
expected 'from' and instead saw 'def'.
expected '(string)' and instead saw 'main'.
expecting semicolon.
unrecoverable syntax error (7% scanned)
------------------------------
Paul Bishop
Original Message:
Sent: Tue November 19, 2024 09:14 AM
From: Jason VenHuizen
Subject: Need Autoscript help
This works on Run Action and Init. The Run Action evaluates when you change the value and the Init evaluates when the record is opened so it ensures that the fields are made read-only on init and whenever the checkbox is updated.
Do you have any details on what those errors are?
Jason
------------------------------
Jason VenHuizen
Sharptree
https://sharptree.io
https://opqo.io
Original Message:
Sent: Tue November 19, 2024 09:12 AM
From: Paul Bishop
Subject: Need Autoscript help
I'm getting 2 errors


------------------------------
Paul Bishop
Original Message:
Sent: Tue November 19, 2024 07:55 AM
From: Jason VenHuizen
Subject: Need Autoscript help
Here is a script that launches off the init and action of the PAIDBYCARD attribute.
It includes the scriptConfig so you can deploy it with the VS Code extension:
https://marketplace.visualstudio.com/items?itemName=sharptree.maximo-script-deploy
Let me know if you have any questions.
Regards,
Jason
from psdi.mbo import MboConstantsdef main(): # If this is called in the context of a work order Mbo save and the PAIDBYPCARD field is true, then make the additional fields required. if 'mbo' in globals() and mbo.isBasedOn("WORKORDER") and mbo.getBoolean("PAIDBYPCARD"): mbo.setFieldFlag("PCARDAMOUMT",MboConstants.REQUIRED, True) mbo.setFieldFlag("PCARDHOLDER",MboConstants.REQUIRED, True) mbo.setFieldFlag("PCARDPAIDDATE",MboConstants.REQUIRED, True) else: mbo.setFieldFlag("PCARDAMOUMT",MboConstants.REQUIRED, False) mbo.setFieldFlag("PCARDHOLDER",MboConstants.REQUIRED, False) mbo.setFieldFlag("PCARDPAIDDATE",MboConstants.REQUIRED, False)main()scriptConfig="""{ "autoscript": "WORKORDER.SAVE", "description": "Make additional fields required if a p-card is used.", "version": "", "active": true, "logLevel": "ERROR", "scriptLaunchPoints": [ { "launchPointName": "WORKORDER.PAIDBYPCARD.INIT", "launchPointType": "ATTRIBUTE", "active": true, "description": "Evaluate if additional fields should be required on initialization", "objectName": "WORKORDER", "attributeName": "PAIDBYPCARD", "initializeValue": true } , { "launchPointName": "WORKORDER.PAIDBYPCARD.ACTION", "launchPointType": "ATTRIBUTE", "active": true, "description": "Evaluate if additional fields should be required when PAIDBYPCARD is checked or unchecked", "objectName": "WORKORDER", "attributeName": "PAIDBYPCARD", "runAction": true } ] }"""
------------------------------
Jason VenHuizen
Sharptree
https://sharptree.io
https://opqo.io
Original Message:
Sent: Mon November 18, 2024 10:23 AM
From: Paul Bishop
Subject: Need Autoscript help
In the workorder table I created a field called PAYBYPCARD and it is defined in Maximo as a yes/no field
When a workorder is saved, I need that field to be evaluated to see if it has been checked. If it has been checked I need workorder to require 3 other fields to be filled out.
Python script
#PAIDBYPCARD SCRIPT
if PAYBYPCARD == 1:
PCARDAMOUMT=True
PCARDHOLDER=True
PCARDPAIDDATE=True
I also tried this version:
#PAIDBYCARD SCRIPT
if PAIDBYPCARD == 'YES':
pcardamount_required=True
pcardholder_required=True
pcardpaiddate=True
When activated it is giving me a boolean java language exception if I check mark the field
Any assistance is greatly appreciated
------------------------------
Paul Bishop
------------------------------