Maximo Open Forum

 View Only

 Automation Script to test for Attribute Change of Value

Jump to Best Answer
  • Customizations
Randy Prosser's profile image
Randy Prosser posted 06-24-2022 13:54
I am trying to write an automation script using javascript to test if the vendor was changed on a PO when the user tries to save it. I have seen some examples of testing for previous values when it was changed within the script but is there a way to test if it was changed before the script was executed? We use SQL Server and we had a trigger that would check the  inserted and deleted tables to see if there was a change made but not sure how to do that here. I want to see if the values are different. Sometimes the user will change the value but before they save it they will change it back. Thanks for any advice given here.

Steven Shull's profile image
Maximo Certified Steven Shull Best Answer
While you can pull from the database, there is no need to do that here. The MboValue exposes an initial value that doesn't change.

if vendor.getInitialValue().asString()!=vendor.getCurrentValue().asString():

That should let you know what it was read from the database compared to what it is currently.​
pavan Kumar's profile image
Maximo Certified pavan Kumar
Hi Randy,

I can suggest to you, There is a concept of Audit Tracking check for the particular Attribute in database configuration.

We can track the Changes made on that Attributes.,the%20ISPRIMARY%20and%20PERSONID%20attributes.
Arul Jefferson's profile image
Arul Jefferson
Hi Randy,

Hope you are trying to fetch the values from DB which was previously committed. You can use MXServer object to get that from DB.

 Python sample:

from psdi.server import MXServer
poSet = MXServer.getMXServer().getMboSet("PO", mbo.getUserInfo())
poSet.setWhere("ponum='xxxxx' and siteid='yyyy'")
po = poSet.getMbo(0)

xxxxx --> Replace it with the po number from current record
yyyy --> Replace it with the siteid from current record