Maximo formula that uses a custom formula function/automation script?

谁说我不能喝 提交于 2020-04-16 03:30:10

问题


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:

  1. Create an automation script:

  2. Add/Modify Formula Function:

  3. Add/Modify Formula For Attribute:

  4. Create a WO. Save it so that the attribute formula is invoked.

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!