2

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: enter image description here

  2. Add/Modify Formula Function: enter image description here

  3. Add/Modify Formula For Attribute: enter image description here

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

  5. Error:

enter image description here

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?

User1974
  • 276
  • 1
  • 17
  • 63

2 Answers2

2

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")
Tran Viet
  • 61
  • 3
  • This could be a good workaround but I'd refrain from modifying data within the `validate` event. I'd use the `action` event instead. – JPTremblay Jan 24 '20 at 14:56
  • @JPTremblay Are you aware of a safe way to get an automation script to fire ***after*** a formula? – User1974 Jan 25 '20 at 00:55
  • I don't know. I would need to look at the Formula framework in details. Why would you want to do that? Formulas are specialized features and a subset of what an [attribute] automation script can accomplish. Basically, if you're not calculating a number, you should switch to an autoscript. – JPTremblay Jan 27 '20 at 13:59
  • In this case, we can have an auto script that overwrite the 0 value with a null on the Work Order object's Save event. It will ensure the value is overwritten after the formula. Will it work for you? – Tran Viet Jan 31 '20 at 12:33
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?

JPTremblay
  • 900
  • 5
  • 8