Wednesday, 24 April 2019

Loops in Automation Script | Maximo

#looping
--for loop
LineSet = mbo.getMboSet("INVUSELINE")
for i in range ( 0, LineSet.count() ):
line = LineSet.getMbo(i)
.... code here

--while loop-------------
LineSet = mbo.getMboSet("INVUSELINE")
line = LineSet.moveFirst()
while (line):
...code here
line = LineSet.moveNext()

----
assetSet = mbo.getMboSet("Asset")
asset = assetSet.moveFirst()
while(asset):
....code here
asset = assetSet.moveNext()

Monday, 22 April 2019

Limit SR Classification based on other attributes

1. Copy classfication diaglog from Library.xml and paste it into presentation (sr.xml) file.
<dialog id="associateClassification" label="Classify">
        <tree beanclass="psdi.webclient.beans.assetcat.AssociateSpecBean" allowqualifiedrestriction="true" height="250" id="associateClassification_tree" maxchildren="1000" relationship="CLASSSTRUCTURESR"  openfirstlevel="false" width="600">
            <treenode displaykeyattribute="false" displayobjectname="false" id="associateClassification_tree_node1" keyattribute="classstructureuid" objectname="CLASSSTRUCTURE">
                <treeattribute dataattribute="classificationid" display="true" id="associateClassification_tree_node1_attr1"/>
                <treeattribute dataattribute="classificationdesc" display="true" id="associateClassification_tree_node1_attr2"/>
            </treenode>
        </tree>
        <buttongroup id="associateClassification_2">
            <pushbutton default="true" id="associateClassification_2_2" label="Cancel" mxevent="dialogcancel"/>
        </buttongroup>
</dialog>
2. create a new relation in SR Object for Classstructure as child object

commoditygroup=:commoditygroup and contract=:contract

3. import sr.xml again and good to go.


Thanks to Haris who did it atlast.


Tuesday, 16 April 2019

Create new Crontask based on Automation Script | Maximo



Step 1. Create a Script with any Name, as in my Example my Script Name is CRONAUTOMATIONSCRIPT


from psdi.server import MXServer
from psdi.util.logging import MXLoggerFactory

log = MXLoggerFactory.getLogger("maximo.script.aqautoscript")

mxserver = MXServer.getMXServer()
userInfo = mxserver.getSystemUserInfo()

 # arg = crontask scriptarg parameter 
if instanceName and scriptName and  arg:
    AssetSet = mxserver.getMboSet("ASSET", mxserver.getSystemUserInfo())
    AssetSet.setWhere("ASSETNUM = '" + arg + "' ")
    AssetSet.reset()
    asset = AssetSet.getMbo(0)
    if asset:
        asset.setValue("description",arg)
    AssetSet.save()
    
log.info('\n instanceName is: ' + instanceName )
log.info('\n ARG is: ' + arg)
log.info('\n Automation Script name: ' + scriptName)

Monday, 8 April 2019

Set Multiple fields readonly

from psdi.mbo import MboConstants
fields = ['DESCRIPTION','ITEMTYPE', 'ORDERUNIT']
itemMbo.setFieldFlag(fields, MboConstants.READONLY,False)

Populate GL attribute in All Lines at ONCE from Header | IBM Maximo

Update all lines in Inventory Usage application from header level.

for instance in this example we are using a GL Debit account field on header level, and when we enter values in it; it will be copied into all lines.

To do this we will run a simple automation script using jython:

Attribute Launch Point:

Script: GLDEBIT_INVUSAGE
Langauge: jython

Launch Point:
Object: INVUSE
Attribute: CUXGLDEBIT
Event: Validate

Script Code:
lineSet= mbo.getMboSet('INVUSELINE')
line= lineSet.moveFirst()
while (line):
    line.setValue("GLDEBITACCT",mbo.getString("CUXGLDEBIT"))
    line = lineSet.moveNext()

Monday, 1 April 2019

Add Default Value to Lookup for Filtering | IBM Maximo



Export Lookup.xml

find lookup table tag and just paste default value tag into it, see below example:

    <table id="laborcraftrate" inputmode="readonly" selectmode="single">
        <tablebody displayrowsperpage="20" filterable="true" filterexpanded="true" id="laborcraftrate_lookup_tablebody">
            <tablecol dataattribute="orgid" id="laborcraftrate_lookup_tablebody_col_1" mxevent="selectrecord" mxevent_desc="Go To %1" sortable="true" type="link"/>
            <defaultvalue dataattribute="contractnum" defaulttype="query" id="laborcraftrate_lookup_tablebody_default" value="BEDFORD"/>
        </tablebody>
    </table>
import lookup.xml again.

we are done :)