3

I have an automation script in Maximo 7.6.1.1 that updates custom fields in the WORKORDER table.

I want to execute the automation script when the LatitudeY and LongitudeX fields (in the WOSERVICEADDRESS table) are edited by users.

What kind of launch point do I need to do this?


Edit:

For anyone who's learning automation scripting in Maximo, I strongly recommend Bruno Portaluri's Automation Scripts Quick Reference PDF. It doesn't have information about launch points, but it's still an incredibly valuable resource.

I wish I'd known about it when I was learning automation scripting...it would have made my life so much easier.

User1974
  • 276
  • 1
  • 17
  • 63

2 Answers2

4

You can create an attribute action launch point on the latitudeY field and another on the longitudeX field. These will trigger whenever each field is modified, so it will fire once when the latitudeY field was changed, again if the longitudeX field is changed, again if the longitudeX field is changed again, and so on. This is also all before the data is saved, so the user may choose to cancel their changes, but the scripts will still have fired.

You could also make an "on save" object launch point for WOSERVICEADDRESS (if that's what is actually being updated via the map). This will run any time data in the object is saved, so you would have to do the extra checks of seeing if either of those fields have changed and then do your logic, but at least it would run once and only if the user commits to their changes.

Dex
  • 1,241
  • 6
  • 13
  • Thanks Dex. Regarding this point: *"...you would have to do the extra checks of seeing if either of those fields have changed and then do your logic..."* --- Do you know how I could perform this check? – User1974 Dec 07 '19 at 15:55
  • 2
    There is an "isModified()" method on the MboValue field class (which you can get from the Mbo record class with "getMboValue"), but that will just tell you that someone changed the value in the field at least once. If they changed it from X to Y and then back from Y to X, Maximo will still tell you it was modified. https://developer.ibm.com/static/site-id/155/maximodev/7609/maximocore/businessobjects/psdi/mbo/Mbo.html – Dex Dec 08 '19 at 16:39
  • 2
    From that MboValueData class, there is also a "getInitialValue" method that you could compare against instead, to make sure it really is different. https://developer.ibm.com/static/site-id/155/maximodev/7609/maximocore/businessobjects/psdi/mbo/MboValue.html I think if you bind the field the automation script settings that you get an implicit "_initial" variable that also gives you that initial value to compare against. Beware that in both cases that gives you MaxType class back, not a String. So you have to worry about nulls and you have to get the String from the class. – Dex Dec 08 '19 at 16:41
  • So the `isModified()` method is really an indication of whether the record has *ever* been modified since it's original creation (or not)? – User1974 Dec 08 '19 at 19:40
  • 2
    @User1973 No, it will return whether it was modified since instanciation (loaded in memory). Regarding your solution, I'd lean towards the SAVE event. – JPTremblay Dec 09 '19 at 16:08
  • @JPTremblay In a dead-simple test, I'm trying to use an automation script to update a WORKORDER field after the WO is created or updated. I can get it to work where `Events = Save; Save = Add`. But none of the other combinations of `Save` are working for me. For example, I can't get `Save = Add, Update; AfterSave` to work. Any tips? https://i.stack.imgur.com/OUygB.png – User1974 Dec 09 '19 at 20:03
  • If you want your script to be triggered on `Add` and `Update`, you need to check both boxes. – JPTremblay Dec 09 '19 at 20:07
  • The "before save" part on the right is independent of the add and update on the left. You first select which kinds of save you want this to trigger on. Only when a *new* record is saved? Only when an existing record update is saved? When either save happens? Select all that are appropriate. – Dex Dec 10 '19 at 02:50
  • 1
    Then, Maximo asks you at which point _during_ those selected saves do you want the script to trigger. During/before the "action" phase and when the data is still changeable (before the save method)? After the "action" phase and when the data should be static/unchanging (after save)? Or after the data has been committed to the database? – Dex Dec 10 '19 at 02:51
0

Related:

Populates WORKORDER.WOSAX and WORKORDER.WOSAY (custom fields) from the values in WOSERVICEADDRESS.LONGITUDEX and WOSERVICEADDRESS.LATITUDEY.

woMbo=mbo.getOwner()
longitudex=mbo.getString('longitudex')
latitudey=mbo.getString('latitudey')
if woMbo is not None:
  wosax=woMbo.getString('WOSAX'); 
  wosay=woMbo.getString('WOSAY');    
  if longitudex!=wosax:
      woMbo.setValue('WOSAX',longitudex)
  if latitudey!=wosay:
      woMbo.setValue('WOSAY',latitudey)

The launch points are Attribute Launch Points, not Object Launch Points.

enter image description here


enter image description here

User1974
  • 276
  • 1
  • 17
  • 63