问题
In Maximo 7.6.1.1:
I would like to create an attribute formula that uses a custom formula function/automation script.
I've tried doing it with the steps below, but unfortunately, I get an error when I try to use it in WO Tracking:
BMXAA3761E - The event has failed. Ensure that the event is registered correctly.
See the log file in the APP HOME directory for more details about the error.
null
Steps:
Create an automation script:
Add/Modify Formula Function:
Add/Modify Formula For Attribute:
Create a WO. Save it so that the attribute formula is invoked.
Error:
From the SystemOut log:
Caused by:
java.lang.NullPointerException
at com.ibm.tivoli.maximo.expression.FormulaMboEventListener.preSaveEventAction(FormulaMboEventListener.java:213)
at psdi.server.event.EventTopic$Subscription.preSaveEventAction(EventTopic.java:731)
at psdi.server.event.EventTopic.preSaveEventAction(EventTopic.java:342)
Does anyone know why I'm getting this error?
Related question here: Can Maximo formulas return null?
回答1:
Not sure what problem are you trying to solve. If you're just trying to play around with formula, I don't have much experience with it, but from what I understand, it can only return a number. So returning null is not possible. (Although there is a SETVALUENULL function which can be used to set a different field to null, but the function itself returns 0 and 1).
If the purpose is to return the X, Y coordinate value to Work Order from Asset/Location/Service Address, and setting it to null when there is no value, how about we still using standard formula and let it returns a 0 when everything is null. Then, we create a separate attribute launchpoint script on "validate" event of the ERI attribute, check to see if the value is 0, then we will overwrite it with a null using this code:
if mbo.getDouble("eri") == 0:
mbo.setValueNull("eri")
回答2:
From what I see, this preSaveEventAction
method is not expecting a null
value and voluntarily crashes. Look at the com.ibm.tivoli.maximo.expression.Expression.eval()
method from the Javadoc. It is returning a BigDecimal, a clue that a formula should return a number.
https://developer.ibm.com/static/site-id/155/maximodev/7609/maximocore/businessobjects/
So the reason you're getting this error seems to be because your script returns an invalid value, same as here: Can Maximo formulas return null?
来源:https://stackoverflow.com/questions/59888911/maximo-formula-that-uses-a-custom-formula-function-automation-script