In some cases Maximo allows to perform bulk updates using actions on the List View. For example, you can set the timezone of multiple assets by selecting the Associate Time Zone on the List View of the Assets application and then a dialog will appear to perform a massive update on all the selected records.
In many cases we need to provide the same feature for some other fields. In this post I will demonstrate how to implement a bulk update feature to set the value of an attribute for a set of selected records in any Maximo application. The implementation is based on the technique described in this post and uses:
- Non-persistent object
- Custom dialog in the application
- Signature Option in the application
- Automation script to apply the update on the selected records
In the example I will build a custom dialog to set the asset’s Priority attribute. Lets start…
Non-persistent Object
The custom dialog will be based on a non-persistent object so we first need to create it using the Database Configuration application.
- Object: MXDASSETBULKUPD
- Description: Non persistent object for the Update Asset Priority dialog
- Persistent: False
- Attributes:
- PRIORITY – Title: Priority – Same as: ASSET.PRIORITY – Required
Apply database configuration changes. It shouldn’t be necessary to activate the admin mode.
Application dialog
Open Application Designer and download the WOTRACK application definition. Edit the XML file with a text editor. Scroll down to the end of the file and paste the dialog definition just before the ‘presentation’ end tag.
<dialog id="mxdassetbulkupd" label="Update Asset Priority" mboname="MXDASSETBULKUPD">
<section border="true" id="mxdassetbulkupd_1">
<sectionrow id="mxdassetbulkupd_11">
<sectioncol id="mxdassetbulkupd_111">
<section id="mxdassetbulkupd_1111">
<textbox dataattribute="PRIORITY" id="mxdassetbulkupd_PRIORITY"/>
</section>
</sectioncol>
</sectionrow>
</section>
<buttongroup id="mxdassetbulkupd_2">
<pushbutton id="mxdassetbulkupd_21" label="OK" mxevent="dialogok"/>
<pushbutton id="mxdassetbulkupd_22" label="Cancel" mxevent="dialogcancel"/>
</buttongroup>
</dialog>
Note that the I have used the mboname property to tell Maximo on which object the dialog is based.
Application Action
To display the Update Priority action on the List view of the Asset application we have to create a signature option and link it to the action.
Open the Asset application in Application Designer and select the Add/Modify Signature Options. Create a new signature option with the following properties:
- Option: MXDASSETBULKUPD
- Description: Update Priority
- Advanced Option: Warning appears when this action is selected from the List page…
Now select the Add/Modify Select Action Menu and crete the Update Priority action as follows:
- Element Type: OPTION
- Key Value: MXDASSETBULKUPD
- Position: 999
- Subposition: 0
- Tabs: LIST
Now we must grant MAXADMIN (and all the relevant user groups) to view and click on the Update Priority action we have just created.
You have to logout from all MAXADMIN sessions and login back in order to see the Update Priority action in the Asset application. By clicking on the action it will display our custom dialog. However, it will not perform the bulk update since we haven’t yet implemented the desired logic.
Automation Script
The massive update action will be handled by save event on the non-persistent object MXDASSETBULKUPD that on which the dialog is based.
Create an automation script as follows:
- Script with Object Launch Point
- Launch Point: MXDASSETBULKUPD – Asset bulk update
- Object: MXDASSETBULKUPD
- Event: Save – Add – Before Save
- Script language: python
Script
#--------------------------------------------------------------------------
# Script: MXDASSETBULKUPD
# Launch Point: MXDASSETBULKUPD - Save - Add - Before Save
# Handle the Bulk Update dialog OK button
#--------------------------------------------------------------------------
from psdi.mbo import MboConstants
from psdi.webclient.system.beans import ResultsBean
# to get the non persistent object of the dialog we need a small trick
mbo = mboset.getMbo(0)
priority = mbo.getString("PRIORITY")
# get AppInstance object to retrieve UI properties
app = service.webclientsession().getCurrentApp()
# get the MboSet from the app
assetSet = app.getResultsBean().getMboSet()
# this is True if the Select Records check boxes are displayed
isTableSelect = app.getResultsBean().getTableStateFlags().isFlagSet(ResultsBean.TABLE_SUBSELECT_ON)
asset = assetSet.moveFirst()
while (asset):
# if Select Records is displayed we have to take action on selected records only
# if Select Records is NOT displayed we have to take action on all records
if asset.isSelected() or not isTableSelect:
asset.setValue("PRIORITY", priority)
asset = assetSet.moveNext()
assetSet.save()
The smart trick here is to use the WebClientSession.getCurrentApp() method to get the AppInstance object and retrieve the MboSet and detect if the Select Records is selected. After that, the script cycles through the MboSet and sets the priority of all the selected records.
Final Test
Now everything is ready and it’s time to test. Here is what you should see.
All the selected assets will be updated with the priority specified on the bulk update dialog.