Thursday, 20 February 2020

IBM Maximo : Bean Class reference information



In this post I will provide some reference information about methods in Maximo bean classes and typical use.

Methods in Bean Class:

1. RESET method:
     This method is called when a new filter is applied for the dialog's MboSet. 
              @see psdi.webclient.system.beans.DataBean#reset()
              @Override
              public void reset() throws MXException
               {   
                 try
                   {   
                     //saveCurrentSelection();
                   }
                 catch (RemoteException e)
                   {
                     //handleRemoteException(e);
                   }
                 super.reset();
                }


2. CALL method:

     /* 
     * This method is called whenever an event is generated in the dialog (e.g. OK button is pressed). 
     */
    @Override
    public int callMethod(WebClientEvent event) throws MXException {
        //ToDo Custom logic here
        return super.callMethod(event);
    }

3. INITIALIZE method:
     This method is used to initialize values on dialog. 
              @Override
    protected void initialize() throws MXException, RemoteException
    {
        //ToDo custom logic here;
        super.initialize();
    }

IBM MAXIMO : UPLOAD DOCKLINKS ATTACHMENTS USING REST API


In this post I will explain in details how to upload attachments to Maximo record using REST API.


I will be using Work Order to explain this use case.

First step is to configure Object Strcture having required objects as in this case WorkOrder and DOCLINK

I have created Object Strcture as below :

Object Structure : RESTWODOCLINKS
Description : Upload WO Attachment using REST API

Its consumed by Integration and includes Workorder and DOCLINKS objects.















Next step is to configure security for Object Structure to grant access to specific groups which is being used by REST API call user. 
You can refer my other post IBM Maximo REST API Example - Change Person/User/Labor status for the same.
maximo REST api













maximo rest api











If you miss to configure object structure for respective group you might get error like below :




Next we are going to submit REST request , I will be using Postman client for the same and detailed explanation of postman parameters and rest/oslc URLs is explained in my post here @  IBM Maximo REST API Example - Change Person/User/Labor status .

I have  created sample RESTTEST Workorder to be used in this example.
This record can be fetched with REST URI as below  sample URI format is
http://host:port/maximo/oslc/os/RESTWODOCLINKS/_QkVERk9SRC9SRVNUVEVTVA--?lean=1
maximo rest api













Now I am going POST REST call using Postman client.

I am using sample JSON paylod as below to upload attachment against Workorder :

Postman sample POST request URL is  http://host:port/maximo/oslc/os/RESTWODOCLINKS/_QkVERk9SRC9SRVNUVEVTVA--?lean=1

{
"wonum": "RESTTEST",
"siteid": "BEDFORD",
"orgid": "EAGLENA",

"doclinks":[
{
    "ADDINFO": "1",
     "COPYLINKTOWO": "0",
     "DESCRIPTION": "Example Attachment via REST API",
"DOCUMENT": "Test via Rest API",
"OWNERTABLE": "WORKORDER",
"UPLOAD": "1",
"NEWURLNAME": "www.ibm.com",
     "urltype":"FILE",
     "documentdata":"aGV5IGhvdyBhcmUgeW91",
     "doctype":"Attachments",
     "urlname":"SampleREST-Upload.txt",
     "OWNERID" : "133634"
}
]
}

maximo rest api










This POST request then successfully adds Attachment against workorder :

maximo rest api










If you want to achieve same thing using Web Service you can refer IBM blog @ IBM Maximo: Iimport attachments into MAXIMO using MIF Web Services.

Additionally IBM REST API Guide can be referred @ IBM Maximo REST API Guide

MAXIMO: REST API Example - Change Person/User/Labor status

IBM MAXIMO REST API EXAMPLE  - CHANGE PERSON , USER , LABOR STATUS VIA REST CALL


 In this post I will explain in details how to use Maximo's REST API framework to update data in   Maximo with the example of changing Person status and status of associated User and Labor   records.


Object Structure setup :


 I am duplicating OOB MXPERSON object structure. I have removed related children objects , verified NP_STATUSIFACE and NP_STATUSMEMO fields included , STATUS and STATUSDATE fields had inbound restrictions applied etc.

maximo REST api













Next we have to configure Object Structure Security , starting version 7.6.0.5 IBM introduced capacity to grant access at Object Structure level. Refer below screenshot.

maximo REST api















Additionally we need to grant Object Structure access to group /User which is being used by REST to update the records. Example screenshot :

maximo REST api














Automation Scripts :


 In this use case I am going to use newly enabled capability of Integration Launch Points.
 I am going to create two Object Structure based Action Processing launch points for Activation   and Deactivation of Person/User/Labor records using REST calls.

a) Activation Script :
    Crete Integration Launch Point with details as below :
  • Type of Integration : Object Structure
  • Object Structure : Select Object created earlier in step above , RESPERSON
  • select "Action Processing" and provide Action name e.g. "ACTIVATE" to be called as REST
  • Maximo will automatically create script name as "OSACTION.RESTPERSON.ACTIVATE"
  • Provide description for script e.g. Activate Person and related associated Labor and User via REST
  • Follow remaining areas and add automation script logic.
       Refer below screen shots :
   
maximo REST api
   
maximo REST api














 b) Deactivation Script :
Follow similar steps as above and create script for Deactivation
Crete Integration Launch Point with details as below :

  • Type of Integration : Object Structure
  • Object Structure : Select Object created earlier in step above , RESPERSON
  • select "Action Processing" and provide Action name e.g. "INACTIVATE" to be called as REST
  • Maximo will automatically create script name as "OSACTION.RESTPERSON.INACTIVATE"
  • Provide description for script e.g. Activate Person and related associated Labor and User via REST
  • Follow remaining areas and add automation script logic.
       Refer below screen shot:
maximo REST api













Associating Action Definitions with Object Structure : 

 Now as we have defined Activate and Inactivate action processing automation scripts , these actions 
 needs to be associated with Object Strcture/s.
 Using select action "Action Definition"  as below :
  Name : ACTIVATE
  Description : Activate Person/User/Labor via REST call
  Implementation Type : script
  Script : OSACTION.RESTPERSON.ACTIVATE

  Name : INACTIVATE
  Description : De-Activate Person/User/Labor via REST call
  Implementation Type : script
  Script : OSACTION.RESTPERSON.INACTIVATE
maximo REST api

maximo REST api














Testing using REST client : 

  Now we will need to test and I will be using postman as rest client to send Activation and      
  Deactivation requests.
  I have created "TESTUSR" person record and associated Labor and User records for testing      purpose.
maximo REST api


















Also now we have to get REST URI for this person record using object structures apimeta information, verify your system properties for rest webapp url etc.
Sample url can be :https://host:port/maxrest/oslc

Here is my TESTUSR URI to be accessed over REST:

maximo REST api












Now I am going to use this REST URI for person "TESTUSR" and call Activate and Inactivate actions via postman REST client.
Postman needs to set up with parameters like x-method-override , patchtype , contenttype etc.
You can refer below URLs for IBMs JSON/REST API documentation :

Below are screenshots from postman POST request to call INACTIVATE and ACTIVATE actions for TESTUSR Person/User/Labor records.

a) Deactivation REST call via Postman client :
maximo rest api










Maximo result screenshot having records inactivated :
maximo rest api
maximo rest api

maximo rest api













b) Activation REST call via Postman client :

maximo rest api

Similarly associated User and Labor record got activated via this request , I have added below automation script for the same.

Launch Point Type : Object Launch Point
Object : PERSONSTATUS
Events : Save , Add , After Save

maximo rest api
maximo rest api
maximo rest api

Saturday, 8 February 2020

Implement a Refresh List button in Maximo

We all know IBM Maximo is not a monitoring console and has no auto-refresh feature in the start center or in the applications. However, in some situations, we may need a Refresh button to reload the content of a table in a Maximo application.
In this example I have added a button to refresh the Asset History tab in the Locations application.
This little customization does not require Java or automation scripts. It is just the button definition in the application with a small trick.
Open the Application Designer application and open the LOCATION app. Download the application definition. Now edit the location.xml file you have downloaded and search for ‘history_history_table’.
Insert the following XML fragment in bold just before the history_history_table table definition.
<section id="mxlrefresh">
  <buttongroup id="mxlrefreshbtngrp" align="left">
    <pushbutton id="mxlrefreshbtn" label="Refresh" default="true" width="200" targetid="history_history_table" mxevent="reset"/>
  </buttongroup>
</section>
<table id="history_history_table" inputmode="readonly" label="Assets" orderby="assetnum" relationship="PLUSCASSETTRANSMOVED">
...
Update the application definition uploading the location.xml file and you are done. If you now open a location and move to the History tab will see the Refresh button. Move any asset to/from the location (from a different browser window) and then click the Refresh button on the location and you will see a new row appearing.
Here are the explainations of the button attributes I have used:
  • label – This is the text that appears on the button. Change it as you wish.
  • default – Setting this to ‘true’ will highlight the button. It can be removed.
  • width – Size of the button. I have make it slightly bigger. It can be removed.
  • targetid – This must be set to the id of the table you have to refresh. See the example. It allows to place the button outside the table itself and better layout the page.
  • mxevent – Always use ‘reset’ event to force the reload of the table referenced by the targetid attribute.

How it works

For those of you who really want to understand how this little trick works, here is the explaination.
When a Maximo event is triggered from the UI, the framework searches through the application layers until it finds a matching handler in: Actions (including action scripts), DataBean (maximouibeb), Mbo/MboSet (businessobjects).
In our case the ‘reset’ event will flow through all the layers and trigger the MboSet.reset() method. This will clear the MboSet in the memory and force a requery to the database.

IBM Readme for IBM Maximo Asset Management 7.6.1.3 Fix Pack

  Fix Readme Abstract This fix pack updates IBM® Maximo® Asset Management version 7.6.1, 7.6.1.1, and 7.6.1.2 Content IBM Maximo Asset Manag...