Monday, 30 December 2019

Add Estimated Duration into Start Date to Caluclate Finish Date | IBM Maximo

Write and Attribute Launch point on Schedule Start Date on Workorder, 

Script will take 2 inputs: Schedule Start date and Estimated Duration.
Add duration into start date and save the final output in schedule finish date.

Object: Workorder
Attribute: SCHEDSTART, Event: Validate


Script:
from java.util import Calendar
appName = mbo.getThisMboSet().getParentApp()
if appName == 'PLUSPWO' and mbo.getString("sp")  =='01' and mbo.getString("spcontract") == '005' and mbo.getInt("istask")  == 0 and mbo.getInt("historyflag") == 0 and mbo.getString("woclass") == 'WORKORDER' :
    if not mbo.isNull('SCHEDSTART'):
        vSSD = mbo.getDate("SCHEDSTART")
     
        #estduration in minutes
        vEstDuration = mbo.getFloat("ESTDUR")*60
   
        cal=Calendar.getInstance()
        cal.setTime(vSSD)
        cal.add(Calendar.MINUTE, long(vEstDuration))
        vNewSFD =  cal.getTime()
        mbo.setValue("SCHEDFINISH",vNewSFD,2L )

Wednesday, 4 December 2019

Accept Charges: Cannot Log Actuals Against a Work Order | IBM Maximo

We cannot report actual against this work order
or even we can't plan any direct issue material if this checkbox is cleared.

By default, this is Accept Charges checked.  
A checkbox in Work order Tracking the main screen:






Checkbox specifies whether or not the work order accepts charges. If the checkbox is selected (the default), the work order accepts charges. If the checkbox is cleared, the work order does not accept charges, and you cannot enter charges on the work order.

We cannot report actual against this work order
or even we can't plan any direct issue material if this checkbox is cleared.

By default, this is Accept Charges checked. 

Display Duplicate Problem Warning while Creating Workorder | Maximo





Organization > Work Order Options>>Other Organization Options>>
Display Duplicate Problem Warning section.

Maximo will display the Duplicate Problem dialog box when a user enters a work order for an asset that is already entered on another open work order with the same problem code. If the checkbox is selected, Maximo will display the dialog box. If the checkbox is cleared, Maximo will not display the dialog box.

Friday, 22 November 2019

Auto Refresh Start Center | Maximo

 A small javascript snippet we will embed in the startcenter-options.jsp file to reload the page based on the interval. 


path: maximo.EAR\maximouiweb\webmodule\webclient\components\startcenter-options.jsp

just copy the below code and paste before the <table> tag in startcenter-options.jsp file:

<script type="text/javascript">

  setTimeout("location.reload(true)", 60000);

</script>


Saturday, 9 November 2019

Dynamically modifiy the body of Communication Template Jython | IBM Maximo

Recently we have a requirement to modify the content of communication templates based on the record; for instance, put all the lines of a PO into the communication template before sending an email.

Also, this technique can be used to send PO to the vendor by creating a new relationship to get the email id of the vendor from Companies.

1. Create an Object Launch Point automation script with SAVE - ADD - After Save events.
2. put this code as a script. it will call an existing template, modify and send it.

 
if (mbo.getString("STATUS") == "APPR"):
      # whereclause is a string with condition to select a comm.template
      whereclause = "TEMPLATEID ='PO-APPR-MGRR'"

      # Get the Communication template via Asset relationship to send email 
      # mbo is implicit asset object through which we get a template            
      ctMboSet = mbo.getMboSet("$commtemp","COMMTEMPLATE",whereclause);
      ctMboSet.setQbeExactMatch("true")
      ctMboSet.reset()
      ctMbo = ctMboSet.getMbo(0)
     
      corcount = mbo.getMboSet("POLINE").count()
      coractionset = mbo.getMboSet("POLINE")
      txtres = " "
         

Thursday, 12 September 2019

Top N rows in a group by using row_number function | SQL

Let say I have this below data in my table for instance:



and my desired output is as below: Group it by WONUM but also I want to see the 2 records of each group.


Sunday, 8 September 2019

Create a Custom Dialog and Save Values in Custom Object | IBM Maximo

 A requirement is to have a custom dialog box which will be called by Select Action or from workflow during status change for instance:

Below is the simplest workaround by creating a non-persisten attribute in primary object and use it in dialog then run your automation on it and do your logic to store/insert.

Step by step is as beLow:

1. add non persistent attribute in pr ojbect (NP_STATUSMEMO)
2. pr to pojust relationship: ownerid = :prnum and object='PR'
3. add signature: MYDIALOG and grant to maxeveryone
4. add actio menu and attach signature MYDIALOG as option
5. DIALOG IN pr.xml attached below, add required fields to display
6. write ALP for this attribute validate with below jython


Sunday, 18 August 2019

Playing with Dates in Jython Automation Script | IBM Maximo


SimpleDateFormat - String
from java.util import Date
from java.text import SimpleDateFormat

vCurrentDate = SimpleDateFormat("MM/dd/yyyy").format(Date())
vReportDate = SimpleDateFormat("MM/dd/yyyy").format(mbo.getDate("reportdate"))
if vReportDate > '08/18/2019' or vReportDate > vCurrentDate  :
    mbo.setValue("DESCRIPTION",str(vReportDate))


Date Utility - Get Current Date Only (00:00 midnight) 

https://developer.ibm.com/static/site-id/155/maximodev/7609/maximocore/businessobjects/psdi/app/common/DateUtility.html

from java.util import Date
from psdi.app.common import DateUtility

today = DateUtility.getDate(Date())

yesterday = DateUtility.addDays(today, -1)

AddDays = DateUtility.addDays(today, 5)

AddMinutes = DateUtility.addMinutes(today, 2)


 

Thursday, 16 May 2019

Run Report Action if missing in a Custom Application | Maximo

1. Open your application in application designer, i.e. XXPR 

2. Select Action > Add/Modify Signature Options -> New Row(B)

Option: RUNREPORTS

Description: Run Reports

Visible? Yes

OK.

3. Select Action > Add/Modify Select Action Menu > New Row(B)

Element Type: OPTION
Key Value: RUNREPORTS
Position: 20
Subposition: 0
Visible? Yes

4. Grant Access to this Signature from Security Group.

you are done :) 

Tuesday, 14 May 2019

Limit ALN Domain Values based on Complex Business Logic | Maximo

1. Create Custom Condition Launch Point Automation Script
mrline = mbo.getMboSet("MRLINE")
if mrline is not None:
 evalresult = False

2. Create New condition expression:
Type: Class
Class: com.ibm.tivoli.maximo.script.ScriptCustomCondition
Expression: MyScriptName:MyLaunchPoint
3. Attach this condition to any of your ALN domain value.

Automation Scripts within Conditional Expressions to control business logic | Maximo

We are very well aware of these Attribute Launch Point, Object Launch Point, Action Launch Point but today we are going to discuss Custom Condition Launch Point.

Sometimes complex business logic involving conditions that need to be evaluated and cannot be covered in simple conditional expression, therefore we need to evaluate conditions within automation script to take the result into conditional expression.

Its a simple 3 steps process:
1. An automation script to handle all business logic
2. Conditional Expression to have this automation in it.
3. use this conditional expression wherever you want.

1. for instance:
lets create a Custom Condition Launch Point ISWONEW
script name is CHECKIFWONEW
Object: WORKORDER
Launchpoint Type: CUSTOMCONDITION
script:
evalresult = onadd
# evalresult = False or True
evalresult is an implicit variable in Custom Conditional Launch Point

2. Conditional Expression; create new
Name: ISWONEW , name as created a launchpoint in step 1
Expression: CHECKIFWONEW:ISWONEW (scriptname:launchpoint)
Class: com.ibm.tivoli.maximo.script.ScriptCustomCondition


reference: https://expertinmaximo.wordpress.com/2016/08/26/automation-script-for-conditional-expressions/

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)