Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only
  • 1.  Enterprise Service - After User Exit Script not modifying data

    Posted 10/01/24 09:33 AM

    Hi,

    i am trying to modify the person data that gets inserted from MAS Core to Manage (MAS 9.0.1) to set some values in custom fields. I found an example for this here: Enterprise service script (the fourth script)

    So i created a script SYNC.MASPERUSER.USEREXIT.IN.AFTER with the following very basic content:

    from com.ibm.tivoli.maximo.oslc import OslcUtils
    from com.ibm.tivoli.maximo.oslc.provider import OslcJSONStructureData
    
    byteData = irData.getDataAsBytes()
    peruserJo = OslcUtils.bytesToJSONObject(byteData)
    peruserJo.put("CXEMPLOYEENUMBER","1234")
    
    irData = OslcJSONStructureData(peruserJo, osName, None, userInfo, messageType, True)

     

    But for some reason my field CXEMPLOYEENUMBER does not get set. For testing i changed irData to erData but it makes no difference. My script gets called, if i add some service.log() statements i can see them.

    Did i understand something wrong? Do i have an error here? Or is something wrong in the implementation?

    Regards



    ------------------------------
    Andreas Brieke
    IT Service Management Consultant
    SVA System Vertrieb Alexander GmbH
    ------------------------------


  • 2.  RE: Enterprise Service - After User Exit Script not modifying data

    Posted 10/02/24 01:59 AM

    Hello!

    What is triggering that script?

    Which user does it, does the user have rights to modify those data?



    ------------------------------
    Juris Flugins
    ------------------------------



  • 3.  RE: Enterprise Service - After User Exit Script not modifying data

    Posted 10/02/24 02:11 AM

    Hi,

    the inbound transaction from MAS Core to MAS Manage on the Enterprise Service MASPERUSER with user mxintadm triggers this script.

    And as all other values (coming from MAS Core) get set i don't think i have a rights problem. Just my modification to the data is ignored



    ------------------------------
    Andreas Brieke
    IT Service Management Consultant
    SVA System Vertrieb Alexander GmbH
    ------------------------------



  • 4.  RE: Enterprise Service - After User Exit Script not modifying data

    Posted 10/30/24 07:08 AM

    Try to set this flag before set value

     mbo.setFieldFlag([YOUR_ATTR_NAME], MboConstants.NOSETVALUE, 0)



    ------------------------------
    Andrey Ilinskiy
    Handz.on
    https://www.on.de/
    München
    ------------------------------



  • 5.  RE: Enterprise Service - After User Exit Script not modifying data

    Posted 10/02/24 02:42 AM

    t looks like you're on the right track, but there might be a few things to check and adjust to get the script working as expected in MAS (Maximo Application Suite) 9.0.1.

    Here are a few suggestions to help troubleshoot and resolve the issue:

    1. Confirm Field CXEMPLOYEENUMBER Exists

    Ensure that the CXEMPLOYEENUMBER field is properly defined in the system, and it's available in the object structure you're working with. You can do this by checking the Database Configuration in Maximo or through the object structure definition in MAS.

    2. Update the Script for Data Modification

    It seems like you're using the irData object to manipulate the incoming data. Make sure that after modifying the JSON object, you're correctly setting the data back to the irData structure so that it can be persisted. Here's a more explicit way to ensure the changes are applied:

    from com.ibm.tivoli.maximo.oslc import OslcUtils
    from com.ibm.tivoli.maximo.oslc.provider import OslcJSONStructureData

    # Convert irData bytes to JSON object
    byteData = irData.getDataAsBytes()
    peruserJo = OslcUtils.bytesToJSONObject(byteData)

    # Add custom field value
    peruserJo.put("CXEMPLOYEENUMBER", "1234")

    # Update irData with the modified JSON object
    irData = OslcJSONStructureData(peruserJo, osName, None, userInfo, messageType, True)

    # Log the update for debugging purposes
    service.log("CXEMPLOYEENUMBER set to 1234")

    3. Verify irData Modification

    Ensure you are passing the modified irData back into the process so the changes are reflected. Sometimes, scripts in Maximo require explicitly committing the changes for them to be saved.

    4. Test Script on Object Insertion vs. Update

    Make sure that the script is being called at the correct point in the transaction lifecycle. Depending on whether this is during an insert, update, or sync, the behavior might differ. For example, you might need to handle insert operations differently from update operations.

    5. Use erData for Response Modifications

    If your intention is to modify the response data that gets sent back, erData would be the appropriate object to use. However, since you're trying to manipulate data being inserted into Maximo from MAS, irData is likely the right object to work with.

    6. Check Logs for Errors

    If you are already using service.log() for debugging, check the logs in the Maximo Admin Console or SystemOut.log for any warnings, errors, or clues that might indicate why the field is not being set. You can also log the contents of peruserJo before and after modification to ensure the changes are being applied as expected.

    service.log("Before modification: " + str(peruserJo))
    peruserJo.put("CXEMPLOYEENUMBER", "1234")
    service.log("After modification: " + str(peruserJo))

    7. Ensure Proper Context and Permissions

    Confirm that the script is running in a context where it has the necessary permissions to modify the fields and that the field you're trying to update is not being restricted by another process or validation.

    8. Check Object Structure & Mapping

    Verify the object structure configuration that you're working with to ensure that custom fields such as CXEMPLOYEENUMBER are correctly included in the mapping between MAS Core and Maximo Manage.

    By following these suggestions, you should be able to pinpoint why the CXEMPLOYEENUMBER field is not being updated as expected. Let me know if you encounter any specific errors in the logs or need further clarification!



    ------------------------------
    Rakesh Ghoshal
    Principal Solution Architect

    Gulf Business Machines
    E-Mail: rghshal@gbmme.com
    Linkedin: www.linkedin.com/in/rkg-kw
    PO Box 4175, Safat, Kuwait
    General Marketing & Services Representative for IBM WTC
    www.gbmme.com
    ------------------------------



  • 6.  RE: Enterprise Service - After User Exit Script not modifying data

    Posted 10/02/24 03:09 AM

    Hi Rakesh,

    thats all things i already checked. But in detail:

    1) It exists, i'm 100% sure

    2) Your script looks exactly like mine, there's just a log statement and a few comments more. I am not allowed to copy the script 1:1 from the customers system, so my script here is a bit stripped down. In real i have a few more log-statements in it to see the script running (like outputting json, outputting irData etc.).

    3) i logged irData.toString() after modifying and the output looks absolutely okay. Seems like i am modifying the data correctly

    4) I am aware of that, but as far as i have seen all updates from MAS Core come in as SYNC. So currently and for my tests no need to look for insert/update

    5) Correct, i am working on the inbound transaction, so erData should not be the output i need. But as said i tried even that, makes no difference

    6) I don't see any errors in the logs. Indeed i even set maximo.integration to DEBUG to see what is it doing. Without having the correct log statements by hand atm, it seems like my modified irData is not forwarded to the ObjectStructure. OS checks if my field is in the incoming data, but doesn't see any data for it

    7) If i understood this process correct, i am only modifying the incoming Data on the ES before it gets handed to the OS. I am not sure how context & permissions should affect this, but as all other data coming in is correctly handed to the OS and is written to the system i would assume this is correct. Just my modifications are ignored.

    8) OS looks okay and my field is in it.

    To summarize, i already checked all these things. For me it seems like Manage is not taking irData from my script to pass it to the OS, it is taking the irData from before my modifications.

    It feels like this is a bug, but i can't really imagine noone ever stumbled over this. This would mean all *USEREXIT.IN.AFTER script would not work.



    ------------------------------
    Andreas Brieke
    IT Service Management Consultant
    SVA System Vertrieb Alexander GmbH
    ------------------------------



  • 7.  RE: Enterprise Service - After User Exit Script not modifying data

    Posted 10/28/24 05:41 AM

    Hi,

    i got this handled with the help of IBM Support (and feel like being kidded, but who cares).

    Just for the case someone else has the same problem, you are not allowed to write the attribute as UPPERCASE but need to use lowercase.

    So changing the script to 'peruserJo.put("cxemployeenumber", "1234")' did the trick.



    ------------------------------
    Andreas Brieke
    IT Service Management Consultant
    SVA System Vertrieb Alexander GmbH
    ------------------------------