Search This Blog

Tuesday, August 29, 2023

MAXIMO : Email Listener using OAUTH using GMAIL account - 7.6.1.2 /3

 Here I am going to provide details steps for how to configure email listener using GMAIL with OAUTH authentication.


Pre-requisite you should have SMTP configurations set up and emails in Maximo are already working.

You may refer IBM documentation for this - Configuring SMTP.

So once SMTP is properly set up and email sending through Maximo applications works fine , we will need to move to prepare and get OAUTH parameters like Refresh Token , Client ID , Client Secret etc. for email address being used for email listener with OAUTH protocol.

Here I will cover steps for getting these details for Gmail account.

First step is to have email account  : Create a new Gmail account   / you may use your existing Gmail account.

Next steps is work with Google Cloud API to configure and generate/ get required parameters like Client ID , Client Secret and Refresh token for above Gmail account using cloud API library services.

Broadly this can be done using following steps :

1. Set up project using Google cloud dashboard logging in with your Gmail account.

2. Next enable GMAIL API under your project

    


3. Once API is enabled , credentials need to be created for connecting to account via GMAIL API

            

    




After hitting Save and continue , you should provide scope for API access /authorization
         


Now you should be able to download details in JSON format or can copy it from google cloud dashboard like Client ID , Client Secret.

    


Now next step is to get refresh token for this Email configuration/ client ID using postman client :
To get refresh token first we need to get code to establish session with api

URL :   Hit URL from browser in below format and within browser while redirecting it will generate CODE
        

It should ask you to login using your email account 
    

Then you have to click "continue" couple times and it will redirect to your maximo login page / redirect URI provided during credentials creation.
After successful login , you can try putting same above URL again and proceed is similar manner as session was already established this time it will automatically login maximo and URL
will now have auth code 





Postman POST request should be done to get refresh token :
URL :  https://oauth2.googleapis.com/token?
Parameters - client_id , client_secret ( values received in above steps)
redirect_uri : - your maximo url e.g. https://host:port/maximo ( which is used as redirect URL during credentials
creation )
grant_type : authorization_code
     prompt = consent
access_type = offline





This request should give you refresh time on first iteration.

Once you get refresh token you should be able to configure Email Listener within Maximo.





This will now complete Email Listener configuration using OAUTH.

I will continue and update this post for additional configurations like Email Interaction and sample PO workflow where PO status will be changed via email response being listened and processed by email listener.


Friday, August 4, 2023

MAXIMO : MIF Integration Changing status with inbound processing

 

How do we have change status functionality get triggered and record status history when sending inbound transaction with new status than the current one on record ?


Status change is an operation that is performed on stateful Maximo Business Objects. For example, a Person object can be changed from ACTIVE to INACTIVE and back by means of a button or menu selection in the application screen.

In order to perform a status change with an inbound Integration Framework transaction, you must include the STATUSIFACE and NP_STATUSMEMO attributes in addition to the STATUS attribute with the new value, and use the StatefulMicSetIn processing class. (Integrations that are provided with Maximo already use this class or have an integration-specific processing class which is an extension of StatefulMicSetIn.)

Note that the STATUS and STATUSDATE fields should be restricted in the object structure. Verify this in the Inbound Setting Restrictions in the Object Structures application.

STATUSIFACE is a boolean attribute which specifies how the transaction should be processed with regards to status changes:

STATUSIFACE=0 - This transaction will perform the specified Action (Add or Replace for example) on the data, save it, and then, if the new status is different from the existing status, perform a status change operation. Note that an invalid status change, such as attempting to cancel a closed workorder, will cause an error.

STATUSIFACE=1 - This transaction is ONLY a status change. Any data other than the key attributes which identify the record are ignored. If the new status is different than the existing status, perform a status change operation.

STATUSIFACE not present or has a null value : not present or null value are treated as STATUSIFACE=0.

The NP_STATUSMEMO attribute is used for the memo or remark which accompanies the status change. For example, if changing a workorder status, the value of NP_STATUSMEMO will be placed in the MEMO field of the WOSTATUS record that is inserted by the status change.

If you create a custom Object Structure for a stateful Maximo object, you must also add STATUSIFACE (and NP_STATUSMEMO if the status has a remarks or memo component in the status change dialog on the screen) to the Object Structure by adding it as a nonpersistent attribute to the main object in Database configuration. 

You must also specify psdi.iface.mic.StatefulMicSetIn as the processing class in the object structure definition. If you are creating a custom processing class, then it must extend the StatefulMicSetIn class.

Usage

In most cases you will only need to specify a STATUSIFACE of 0. This will ensure that the integration action is carried out and that the status will be changed if the new status is different.

If you plan on sending in transactions that will only change a status, such as approving a workorder or deactivating a person, then you can use the same integration that you use for data updates with status changes, but set STATUSIFACE to 1 and only send the key attribute values which identify the record, such as WONUM and SITEID for a workorder, along with the new status value.

Reference : IBM Technote MIF Changing status with an inbound transaction

Thursday, June 22, 2023

MAXIMO : Reset user password from backend

There are sometimes situations like lower environments like DEV , TEST ,TRAINING etc. gets refreshed from Production and all users get inactivated , password reset to default values and in some situations default values gets changes without notice and you had to wait for onshore counter part to be available to share details .


This can be dealt with updating you user's password from backend , generally developers have such access in development environments.

Below are details how to do this in different flavors of databases : 

First of all, get the encrypted password string of maxadmin user, where  for e.g. password is 'maxadmin'

SQL> Select userid, password from maxuser where userid = 'MAXADMIN'


output :
USERID PASSWORD
--------- --------------------------------
MAXADMIN x'10FE6F4650B2ACB49A2121D7E6133E64'

Now update user's password with this string, so that the password would be same like maxadmin's password

Oracle:
UPDATE maxuser
SET PASSWORD = '10fe6f4650b2acb49a2121d7e6133e64'    --
WHERE userid = 'XXXX' --user

SQL Server:
UPDATE maxuser
SET PASSWORD = 0x10fe6f4650b2acb49a2121d7e6133e64    --0x
WHERE userid = 'XXXXX' --user

DB2:
UPDATE maxuser
SET PASSWORD =x'10fe6f4650b2acb49a2121d7e6133e64'    --x''
WHERE userid = 'XXXX' --user


Reference: http://www-01.ibm.com/support/docview.wss?uid=swg21645570

Monday, June 19, 2023

MAXIMO : Automation Script to invoke external URL without Publish Channel or Invocation Channel

Maximo integration capabilities like Publish Channels , Invocation Channels provide way for invoking external service via HTTP calls.


But there are sometimes needs where external API needs to be triggered during processing logic within user interaction and continuation of user activity through API call return/processing.

Get Data from External API Call:

So we can use ScriptService class and its method httpgetasjson to get the data from external API call and then continue maximo operation using the data requested from external api by user's activity.

 service.httpgetasjson(<url>, <userid>, <headers>, <password>)

Here we can call API "URL" and pass connection and header parameters.


Here is sample code snippet :

from com.ibm.json.java import JSONObject, JSONArray

# Invoking an URL

url = "https://www.external-api.com/" userid = api-user passwd = api-pwd # Invoke URL response = service.httpgetasjson(url, userid, None, passwd) status = response.getStatusLine().getStatusCode() obj = JSONArray.parse(response.getEntity().getContent()) if status == 200: # OK else: # error


Push Data to External API :

So we can use ScriptService class and its method httppostasjson to post the 

data from maximo to external API call.

service.httppostasjson(<url>,<userid>,<password>, <headers>, <json>)

Here is sample code snippet

from com.ibm.json.java import JSONObject, JSONArray

# create a JSON object jsonObject = JSONObject() jsonObject.put("equipment", mbo.getString("ASSETNUM")) jsonObject.put("description", mbo.getString("DESCRIPTION")) # Invoking an URL url = "https://www.external-api.com/" userid = api-user passwd = api-pwd # Invoke URL response = service.httppostasjson(url, userid, passwd, None, jsonObject) status = response.getStatusLine().getStatusCode() obj = JSONArray.parse(response.getEntity().getContent()) if status == 200: # OK else: # error

MAXIMO : Automation Script to Route Workflow

Workflow is key feature in IBM Maximo for automating business processes like Workroder lifecycle , Purchase Order cycle etc. 

There are many situations where it would need to trigger specific Workflow process if there are multiple active processes on object as only one process can be enabled for auto initiation. 

Below I will discuss few methods how we can achieve specific workflow process using Automation Scripts : 

 *****WorkFlowService class***** 
 Here in this approach a workflow needing to route with a certain business logic:
***** ScriptService class***** 

 Another approach is to utilize ScriptServiceclass:
Additionally to stop a Workflow Instance: 

We can stop an active workflow instance using WorkFlowService class and its method stopWorkflow.

Friday, June 2, 2023

MAXIMO : Automation Script - Execute SQL for data correction without having DB access

Here is an example of an automation script that can be used to for any data correction situation where it needs to execute update/SQL scripts on backend database directly and it can be done without having direct DB access to execute SQLs using DB client tools. 

For example we are needing to correct PO details such that PO have corrupt status and receipts completion and need back end correction. 

We will need to update latest revision status to APPR and previous revision status to REVISD along with marking receipts complete on latest revision by running SQL Update , Insert statements using automation Script. High level steps :

 1.  We will need to create automation script without any launchpoint. 
 2.  We will have to pass required values in request parameters for identification records to be updated  
      e.g. PONUM , SITED in this case. 
3.   We will call the automation script as rest call passing parameter values and script code will run 
      required SQL statements 
     
 e.g. Update PO details for revisions , insert status history records in POSTATUS etc.

 ****************Code snippet*************************

Using this script we will make a POST request call for Maximo REST API.
The request will be authenticated using your login session or require username and password can be passed in parameters as like any REST API call. 

Automation script is fetching connection key and other details using MXserver references and calling SQL statements 

e.g. Update PO statuses for revisions and insert status history details over the connection established using MXServer. 

Friday, May 26, 2023

MAXIMO: Sample Automation script to access the IBM Maximo REST API

Here is an example of an automation script that can be used to access the IBM Maximo REST API: 

Code snippet

This script will make a GET request to the /api/v1/resources endpoint of the Maximo REST API. 
The request will be authenticated using the API key that is specified in the apiKey variable.

If the request is successful, the response body will be parsed as JSON and the data will be processed. 

If the request is not successful, an error will be handled. 

This is just a simple example of how you can use an automation script to access the IBM Maximo REST API. 

You can use this script as a starting point to create your own scripts that can be used to perform a variety of tasks.

MAXIMO: REST API Inbound Integration Example

The Maximo REST API provides a way to programmatically interact with Maximo data from external applications. 

This can be used for a variety of purposes, such as: Retrieving data from Maximo Updating data in Maximo Creating new records in Maximo Deleting records from Maximo.

In this blog post, I will show an example of how to use the Maximo REST API to import data into Maximo. 

Prerequisites: 
To follow this example, you will need: 
        A Maximo system with the REST API enabled 
        An external application that can make HTTP requests 
        A sample dataset to import into Maximo 

Example: 
     The following example shows how to import a sample dataset into Maximo using the REST API: 


     First, we need to create a new request object. The request object will contain the data that we want  
     to import into Maximo. 

 Code snippet

Next, we need to make a POST request to the Maximo REST API endpoint. 
e.g. The endpoint for importing data is /api/v1/import.
If the request is successful, the response will be a JSON object with the following properties:
   status: The status of the import operation. 
               Possible values are success and error. errors: 
   An array of error objects, if the import operation failed.

Thursday, May 11, 2023

MAXIMO BASICS: Broken Sequence BMXAA8010E - Record Already exists erros

Problem :
    When attempting to add a new Asset into Maximo using the Assets application, the following message  
    is displayed when you click Save Record. 

    BMXAA8010E - An asset with the asset identifier 16,058 already exists. Enter a new asset identifier.

Cause :
    This error can occur after a data load or Migration . 

Resolving The Problem:

  To fix tis error we have two possible solutions: 

     1) Run the script: 
            update maxsequence set maxvalue = ( select max(ASSETID) + 1 from asset)  where                                name = 'ASSETID'; 
 or 2) Run this script: 
            ALTER SEQUENCE assetidseq INCREMENT BY 5000; 
            select assetidseq.nextval from dual; 
            ALTER SEQUENCE assetidseq INCREMENT BY 1; 

Because the example above could have been caused by data load in Maximo, the scripts should help to fix the problem, however Support does not engage on fixing data issues in Maximo environments, so the information above is a reference that should help. 

Sunday, April 16, 2023

MAXIMO : DBC-Scripts for Quick and Easy Migration

Are you looking for a way to migrate changes in Maximo? 

Look no further than DBC script! 

This expert guide explains how it works and offers tips for optimal effectiveness. 

MAXIMO : Automation Scripts Quick Overview

 Maximo Automation

Script

Automation scripts are a powerful Maximo feature that allows you to

automate your business processes. They enable you to create a

custom application and process the data with just a few clicks.



Kindly refer attach PDF for overview

Click here to download PDF here

Monday, February 13, 2023

MAXIMO : Run SQL statements from Automation Scripts

This article details  Maximo automation script  needing to execute plain SQL statements instead of Maximo Mbo and MboSet related methods.


Broadly there are two way's to handle SQL statement exeuction , first is you can simply follow standard java.sql package and use respective connection and allied objects and the next which is recommended one is to use maximo DBShortcut class from framework which supports connection pool optimized way in terms of performance/resource usage and clean up aspects.

Below are sample code snippet which can show how to use these two approaches

1. JDBC Connection:

  from psdi.security import UserInfo

from psdi.server import MXServer
 
vsql = "update workorder set priority='1'
         where wonum=1002"
 mxserver = MXServer.getMXServer()
conKey = mxserver.getSystemUserInfo().getConnectionKey()
cnx = mxserver.getDBManager().getConnection(conKey)
stmt = cnx.createStatement()
stmt.executeUpdate(vsql)
 
stmt.close()
cnx.commit()
mxserver.getDBManager().freeConnection(conKey)

2. DBShortcut Class:

  from psdi.mbo import DBShortcut, SqlFormat

from psdi.server import MXServer
 
vsql = "update workorder set priority='1' where wonum=1002"
 
mxserver = MXServer.getMXServer()
conKey = mxserver.getSystemUserInfo().getConnectionKey()
dbs = DBShortcut()
dbs.connect(conKey)
 
sqf = SqlFormat(vsql)
dbs.execute(1, sqf)
dbs.commit()
dbs.close()