Tuesday, 25 February 2020

Utilization of Logging in Maximo

FATAL - A message logged at FATAL level indicates that the error is very severe and will cause the application not to function at all. This level is used only by the Maximo application framework code to indicate that the Maximo application failed.

ERROR - A message logged at ERROR level indicates that the application would continue to run, but a specific functionality that's processed by the current thread failed and would continue to fail until the processing information is altered.

WARN - A message logged at WARN level indicates that the application would continue to run, but a specific functionality that's processed by the current thread may be operating on some data that might not be appropriate.

INFO - A message logged at INFO level indicates a general message that highlights the progress of the specific functionality that's processed by the current thread.

DEBUG - A message logged at DEBUG level indicates a general message that provides fine-grained information about the progress of the specific functionality that is being processed by the current thread.

NOTE: The DEBUG level is used to log messages that are useful for customers, support and development to diagnose problems in detail, but it is extremely verbose and should be used sparingly.


FATAL > ERROR > WARN > INFO > DEBUG

This means that if a logger is enabled for INFO level, it would accept FATAL, ERROR, WARN level messages and discards DEBUG level messages.



For more info please check this IBM Tech note Logging in Maximo

Tuesday, 18 February 2020

Check Budget with Oracle ERP Through Publish channel and set flag 1 or 0 on PR and PO.

Check Budget with Oracle ERP Through Publish channel and set flag 1 or 0 on PR and PO.

Create End point for publish channel that needs to be used for Publish channel with ERP.

Publish Channel Endpoinnt = MEP

Define external system and publish channel for outbound transactions and Enterprise Service for inboaund transactions

Publish channel  = BDGT_CHECKINTERFACE
Enterprise Service = BDGTCHK_POINTERFACE

once everything is done for integeration side
Send request to ERP through automataion below.


create script with action launch point.
object = 'PO' , object = 'PR' in launch points.


import sys
from psdi.util.logging import MXLoggerFactory
from psdi.mbo import MboConstants
from psdi.util.logging import MXLogger
from psdi.iface.mic import MicService
from psdi.server import MXServer
from psdi.mbo import *
from psdi.webclient.system.session import WebClientSession
from time import sleep
from psdi.security import UserInfo
from psdi.server import MXServer

Uses of UIContext (bean) via automation Scrip to Access List View Filterst | IBM Maximo

There are scenarios where you need to access the current List View filter (including QBE and user-applied conditions) directly from an Automation Script.

Maximo provides access to this information through the UIContext and the active Web Client session.

Therefore, The following snippet demonstrates how to retrieve the effective WHERE clause applied in the current application’s list view (including both user filters and QBE criteria).


Traditional Approach

from psdi.common.context import UIContext

wclause = UIContext.getCurrentContext().getWebClientSession().getCurrentApp().getResultsBean().getMboSet().getUserAndQbeWhere()

service.error("", wclause);

-----------
and now More Concise and Readable Approach:

from psdi.common.context import UIContext
wclause = service.webclientsession().getCurrentApp().getResultsBean().getMboSet().getUserAndQbeWhere()

------------


Monday, 10 February 2020

Reconfigure DB2 after a Windows Hostname Change | DB2

1. replace the hostname in db2nods.cfg file at (c:\programdata\ibm\db2\db2copy\db2inst\)

2. open command prompt with admin rights and run these 2 commands to enable editing in registry

db2extsec –r

db2extsec /a DB2ADMNS /u DB2USERS

3. open registry editor (regedit), find and replace host name in all values

HKEY_LOCAL_MACHINE\Software\IBM\DB2


Monday, 27 January 2020

A Custom Solution to Get Survey from User when SR is Resolved | IBM Maximo

This summary is not available. Please click here to view the post.

PMSTATUS table to make history of PM records | Maximo

Maximo doesn't support us to have a history of status changes for Preventive Maintenance applications like XXSTATUS table is available for almost all applications.

We decided to have a history table for PM records also so that we know that who and when actually this record was modified.


1. in database configuration create a new object:

Attribute Type Length
CHANGEBY UPPER 30
CHANGEDATE DATETIME 10
DESCRIPTION ALN 50
DESCRIPTION_LONGDESCRIPTION LONGALN 32000
HASLD YORN 1
MEMO ALN 50
ORGID UPPER 8
PMNUM UPPER 20
PMSTATUSID BIGINT 19
SITEID UPPER 8
STATUS UPPER 20


Wednesday, 22 January 2020

How to Read XML using PHP

Let us start with a simple example, for that we need one simple XML file which might be returned in the response of any SOAP or REST.

1. create an XML file, let say we have this file with the name person.xml

<?xml version="1.0" encoding="utf-8"?>
<persons>
        <person id = "101">
            <name>Abdul Qadeer</name>
            <position>CEO</position>
        </person>
        <person id = "102">
            <name>Umar Adil</name>
            <position>CTO</position>
        </person>
</persons>

2. let's create another index.php file to read person.XML file

Tuesday, 21 January 2020

Usage of MboValueAdapter in Maximo Scripts | Maximo

short version to get the PreviousValue which can only be get via the MboValueAdapter
pstatus= mbo.getMboValue("status").getPreviousValue().asString()

Example a script to get previous status and current status to display message.

pstatus= mbo.getMboValue("status").getPreviousValue().asString()
if mbo.getString("status") == 'COMP' and pstatus == 'WASSET':
   if mbo.getInt("item.rotating") ==  1:
       warngroup = "assrecmsg"
       warnkey = "assrecmsg"


Thanks

Create SR from Conduct an Inspection Module

Conduct and inspection is a new work center in Maximo 7609. The user can conduct inspection base on Asset, Location and Work orders.

One of our requirements is to have an SR again if inspection Fails., below is the solution using automation script.



1) Create Automation Script

In automation Script, we have to select create  SCRIPT Launch POINT
Use the pre-defined structure of the script name OSACTION.MXAPIINSPRESULT.CREATEINSPSR
You can change the CRATEINSPR in the above name  OSACTION.MXAPIINSPRESULT will remain the same.

Use Below Script to Create SR, this script will create SR when the user selects Yes in the inspection form that He/She wants to create SR.


Maximo DocInfo Inbound Processing | IBM Maximo

Create Maximo automation script for inbound document transaction from external system.

--create script for integration
--select enterprise service
--select service name
--SYNC.NPP_DOCINFO.EXTEXIT.IN

from com.ibm.tivoli.maximo.util.mbo import IterableMboSet
from java.math import BigDecimal


from java.io import File
from java.rmi import RemoteException
from psdi.mbo import *
from psdi.util import MXException
from psdi.app.doclink import Docinfo
from psdi.app.doclink import DocinfoSet
from psdi.app.doclink import DocinfoSetRemote
from psdi.app.doclink import DoclinksSetRemote
from java.lang import SecurityException
import sys


erData.breakData()

docinfoid = erData.getCurrentData("DOCINFOID")
dociset = MXServer.getMXServer().getMboSet("DOCINFO",MXServer.getMXServer().getUserInfo('MAXADMIN'))
dociset.setWhere("docinfoid="+str(docinfoid))
dociset.reset()
contentuid = dociset.moveFirst().getString("CONTENTUID")

erData.setCurrentData("CONTENTUID",contentuid)


# Code to delete the file from server
URLTYPE = dociset.moveFirst().getString("URLTYPE");
if (URLTYPE=='FILE'):
    URLNAME = dociset.moveFirst().getString("URLNAME");
    print('**** deletefilefromserver... ')
    deletefile = File(URLNAME)
    if (deletefile.exists()):
        print('**** Deleting file... '+URLNAME)
        deletefile.delete()
        print('**** File Deleted... '+URLNAME)



Item Inspection with Maximo Inpsection Form | Maximo

The new version of Maximo Inspection is based on Work Center, which is built on google polymer.
We create Inspection form and perform Adhoc Inspection for either Asset or Location.

2nd Option is to attach inspection form with Route, Job plan or directly with Work order.

What if we want to inspect something else? let say critical item inspection, can we use inspection module with this.
the answer was NO.

But with this little trick we can use this functionality with almost any application:

1. Create a new application, attach inspection form and result form with it.
2. create a new record, put item number, start the inspection.

below is the step by step instructions to create this.

1. Database Configuration:
create a new object let say (CSPINSPECTION) : add INSPFORMNUM as an addition to your required attributes.

Saturday, 18 January 2020

Express.js in 5 mintues | Node.js

npm install express

my fist HelloWorld application.

var express=require('express');    //use the express module
var app=express();     // create an object of express module
app.get('/', function (req,res){ //create a call back function
    res.send('helloworld'); //send helloworld response
});
var server = app.listen(3000, function(){ make the server listen on 3000
   
});
----

1. using require function we are including the express module.
2. we need to make an object for the express module we just included.
3. create a callback function to be called whenever the user hits our root (/)
4. in the callback function, we are sending a response to the user
5. call a listen to function to make our server listens to client requests on port 3000.
done. use this web address to confirm.
localhost:3000/

Route (/):
routes reads clients input and responds to the request. say GET,POST,PUT,Delete

Friday, 17 January 2020

Access Modifiers in Maximo | IBM Maximo

To use these we need to import one class (from psdi.mbo import MboConstants)

NOACCESSCHECK
NOVALIDATION
NOACTION



mbo.setValue("DESCRIPTION", "Update a read only field", mbo.NOACCESSCHECK)

To update a field and not perform the validation and action events:

mbo.setValue("DESCRIPTION", "Update a field without validation or action", mbo.NOVALIDATION|mbo.NOACTION)

Putting all three together:

mbo.setValue("DESCRIPTION", "Please be careful doing this", mbo.NOACCESSCHECK|mbo.NOVALIDATION|mbo.NOACTION)

Copy value while Duplicating an MBO in automation script | IBM Maximo

 
<MBONAME>.DUPLICATE


or example in this case we will name it WORKORDER.DUPLICATE to intercept the duplicate event. The


mbo is this mbo. 
dupmbo is duplicated mbo. 

lets say we want to copy a value from workorder to the new duplicated workorder. 

create a script with this name, 
<MBONAME>.DUPLICATE

in our example we will name it WORKORDER.DUPLICATE to intercept the duplicate event.


dupmbo.setValue("copiedfrom", mbo.getString("wonum"))

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/