Hi Tim,
Let me give you little more background to make sense of the solution that I presented in my first message. There is an automation script which populates RETIRE_DATE value based on some business logic. We have number of automation scripts running on LOCATION object on different events like save, update for different business solutions. When we were setting up the RETIRE_DATE value from the mbo.setValue("RETIRE_DATE".....) , it took us around 2 hours in client's environment to update the values for records listed in the Result Set. So we have to drop this idea and instead we created a CSV file on the server, created an enterprise service, setup a flatflieconsumer crontask instance to run this update in the background. So user session is not stuck otherwise user can't use Maximo till the time the process was running.
I was looking for a more decent solution to do it through ACTION, if it doesn't work then I will probably go for the following solutions which is working fine in my Demo env.
conKey = ""
con = ""
s = ""
try:
mxserver = MXServer.getMXServer()
userInfo = mxserver.getSystemUserInfo()
conKey = mbo.getThisMboSet().getUserInfo().getConnectionKey()
con = mbo.getThisMboSet().getMboServer().getDBConnection(conKey)
s = con.createStatement()
val = "Update Locations Set RETIRE_DAET = NULL where RETIRE_DATE != NULL"
#val = "Select * from Locations"
logger.info(val)
logger.info("Before executing")
rs = s.execute(val)
logger.info("after execution")
con.commit()
finally:
if s != "":
s.close()
if conKey != "" and con != "":
mbo.getThisMboSet().getMboServer().freeDBConnection(conKey)
------------------------------
Mohammad Hamid Naseer
------------------------------
Original Message:
Sent: Fri April 29, 2022 05:33 PM
From: Tim Ferrill
Subject: 7.6.1.2 - Calling an ACTION in automation script
Mohammad,
I see. I would assume the answer would be yes, but I can't think of a single use case where this would gain you any benefit. You are going to be much better off just setting the value or changing the status directly from the Automation Script rather than trying to call an Action. Even if you were calling an Action Group things are going to be much more efficient if you just perform the steps from the Automation Script itself.
In the example you provided this could be something as simple as mbo.setValue('RETIRE_DATE', None)
.
------------------------------
Tim Ferrill
Solutions Consultant
Intelligent Technology Solutions
tferrill@webuildits.com
www.webuildits.com
@tferrill/@webuildits
Original Message:
Sent: Fri April 29, 2022 05:26 PM
From: Mohammad Hamid Naseer
Subject: 7.6.1.2 - Calling an ACTION in automation script
Hi Tim,
Thanks for your reply. No, I am not updating the current record, instead I want to update all the Location Descriptions with Action.
The reason I am trying to do that, our customer has a custom date field lets' say RETIRE_DATE, This is populated through a process. User don't have access to SQL Developer where he can run an update statement like UPDATE LOCATIONS SET RETIRE_DATE=NULL to set all RETIRE_DATE to null. So we thought we can provide an option to user through Automation Script which will call an ACTION and it will set the RETIRE_DATE to null for all the locations in the LOCATIONS table. User can run this option from drop down menu on Location app.
Now with this background, I tested the above DESCRIPTION example and it perfectly worked fine from ESCALLATION and it setup the DESCRIPTION to NULL for all LOCATIONS in my demo environment. However when I tried to call it from the automation script, it did nothing, so was wondering is it possible to call ACTION from an Automation Script and is it equivalent to calling it from Escalation ?
Thank you,
Mohammad Hamid Naseer
We have requirement where we have a custom field, we want to give option to user to
------------------------------
Mohammad Hamid Naseer
Original Message:
Sent: Fri April 29, 2022 02:19 PM
From: Tim Ferrill
Subject: 7.6.1.2 - Calling an ACTION in automation script
Mohammad,
This is an interesting use case. I'd be concerned that you're trying to open/modify the current record mbo
both in the Automation Script and via Action simultaneously. In my experience Maximo doesn't behave well in that type of scenario.
If you're performing that Action against the current mbo
you're probably better off incorporating the Action behavior into the script itself. Now if you're performing the Action against a related record in some way I could potentially see that working, but be careful if it's part of the current MBO structure.
------------------------------
Tim Ferrill
Solutions Consultant
Intelligent Technology Solutions
tferrill@webuildits.com
www.webuildits.com
@tferrill/@webuildits
Original Message:
Sent: Fri April 29, 2022 02:12 PM
From: Mohammad Hamid Naseer
Subject: 7.6.1.2 - Calling an ACTION in automation script
Hi,
I am calling an ACTION in the automation script. Action sets the value of the DESCRIPTON for all locations to let say "New Description", Automation script runs fine but when I refresh the location screen, it doesn't show me the new descriptions.
However, if I run the same ACTION from an escalation, it updates the location description.
Is it possible to call an ACTION in an automation script ?
mxServer = MXServer.getMXServer()
userInfo = mbo.getUserInfo()
actionSet = mxServer.getMboSet("ACTION", userInfo)
actionSet.reset()
actionSet.setWhere("action = 'SETDESCRIPTION'")
if(not actionSet.isEmpty()):
action = actionSet.getMbo(0)
action.executeAction(mbo)
actionSet.commit()
actionSet.save()
actionSet.close()
Thank you,
Mohammad Hamid Naseer
------------------------------
Mohammad Hamid Naseer
------------------------------
#AssetandFacilitiesManagement
#Maximo