Monday 15 November 2021

Bulk Update any Attribute from List View | Maximo

Update multiple records or even the child records from the list view.
for instance, if you want to update any record in PR table, just write the attribute name
but for Child records like PRLINE; use the standard relationship like PRLINE.orderqty



1.  Create a non-persistent object NP_BULKUPDATE with 2 fields ATTRIBUTEVALUE, ATTRIBUTENAME.

<dialog id="NP_BULKUPDATEDIALOG" label="NP_BULKUPDATEDIALOG" mboname="NP_BULKUPDATE">
    <section id="NP_BULKUPDATEDIALOG_110">
        <sectionrow id="NP_BULKUPDATEDIALOG_111">
            <sectioncol id="NP_BULKUPDATEDIALOG_112">
                <textbox dataattribute="ATTRIBUTENAME" id="NP_BULKUPDATEDIALOG_114" />
                <textbox dataattribute="ATTRIBUTEVALUE" id="NP_BULKUPDATEDIALOG_115" inputmode="required" />
            </sectioncol>
        </sectionrow>
    </section>
    <buttongroup id="NP_BULKUPDATEDIALOG_120">
        <pushbutton default="true" id="NP_BULKUPDATEDIALOG_121" label="OK" mxevent="dialogok" />
        <pushbutton id="NP_BULKUPDATEDIALOG_122" label="Cancel" mxevent="dialogcancel" />
    </buttongroup>
</dialog>

2. create a dialog in application designer and add the above 2 fields into any application, let's say in PR application.



3. Develop an OLP script on NP_BULKUPDATE before Add and good to go. 

from psdi.mbo import MboConstants
from psdi.webclient.system.beans import ResultsBean

# to get the non persistent object
mbo = mboset.getMbo(0)

vATTRIBUTENAME = mbo.getString("ATTRIBUTENAME")
vATTRIBUTEVALUE = mbo.getString("ATTRIBUTEVALUE")

# get AppInstance object to retrieve UI properties list view
app = service.webclientsession().getCurrentApp()
# get the MboSet from the app
parentSet = app.getResultsBean().getMboSet()
#service.error('',str(app))
# this is True if the Select Records check boxes are displayed
isTableSelect = app.getResultsBean().getTableStateFlags().isFlagSet(ResultsBean.TABLE_SUBSELECT_ON)

vParent = parentSet.moveFirst()
while (vParent):
    # 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 vParent.isSelected() or not isTableSelect:
        vParent.setValue(vATTRIBUTENAME, vATTRIBUTEVALUE)
    vParent = parentSet.moveNext()
parentSet.save()


Extension to my confirmation dialog upon deletion post but got the idea from Bruno's article which is here:

No comments:

Post a Comment