Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only

Maximo API - Contextualize Results with User Profile

By Sankar Ganesh V S posted 05/25/26 07:30 AM

  

🔹 When triggering via Maximo data via API — whether from an AI agent or through an external application — it's essential to have the right user profile context in place. 

🔹 The 'MXProfile' object in Maximo holds user information such as the default site, innersite, and authorized sites etc.(https://bportaluri.com/wp-content/MaximoJavaDocs76/psdi/security/Profile.html).

🔹 Using these details we can contextualize the results  according to user profile.

Here's how to retrieve via REST API.  (I have used few MXProfile methods in this example.)

  • Create an OSLC Automation Script in Maximo without any Launch point.

https://github.com/sankargh/maximo_ai_1/blob/main/GET_PROFILE.js

MXServer = Java.type("psdi.server.MXServer")
//Get the userInfo from request
userInfo = request.getUserInfo()
// Get the Mbo Name from Query Parameter
mboName = request.getQueryParam("mboname")
// Get the Profile from MXServer-->MboSet-->Profile
mxServer = MXServer.getMXServer()
mboSet = mxServer.getMboSet(mboName, userInfo)
profile = mboSet.getProfile()
userName = userInfo.getUserName()
defaultOrg = profile.getDefaultOrg()
defaultSite = profile.getDefaultSite()
orgWhereClause = profile.getOrgsString()
siteWhereClause = profile.getSitesString()
var resp = {
    "userName":userName,
    "mboName":mboName,
    "defaultOrg":defaultOrg,
    "defaultSite":defaultSite,
    "orgWhereClause":orgWhereClause,
    "siteWhereClause":siteWhereClause
}
var responseBody = JSON.stringify(resp);
  • Call the script via Maximo REST API -- > {MAXIMO_HOST}/maximo/api/script/{getProfileScript}?lean=1&mboname={mboName}
  • It will return the User Profile details such as 'Default Site' , 'Default Org', 'SiteWhereClause' etc.
  • Use this information to set context for results or futher actions.

https://github.com/sankargh/maximo_ai_1/blob/main/get_profile.py

import requests
import json
import os
from dotenv import load_dotenv
load_dotenv(override=True)
MAXIMO_HOST= os.getenv("MAXIMO_HOST")
MAXIMO_API_KEY = os.getenv("MAXIMO_API_KEY")
payload = {}
headers = {
  'apikey': MAXIMO_API_KEY
}
MAXIMO_WHOAMI_URL = f"{MAXIMO_HOST}/maximo/api/whoami?lean=1" 
def getUserInfo():
  response = requests.request("GET", MAXIMO_WHOAMI_URL, headers=headers, data=payload)
  data=json.loads(response.text)
  return data
userInfo = getUserInfo()
print("\n ** User Details ** ")
for key,value in userInfo.items():
  print(f"{key} : {value}")
getProfileScript = "GET_PROFILE"
def getProfile(mboName):
    MAXIMO_PROFILE_URL = f"{MAXIMO_HOST}/maximo/api/script/{getProfileScript}?lean=1&mboname={mboName}"
    response = requests.request("POST", MAXIMO_PROFILE_URL, headers=headers, data=payload)
    data=json.loads(response.text)
    return data
mboName = "WORKORDER"
userProfile = getProfile(mboName)
print("\n ** User Profile ** ")
for key,value in userProfile.items():
  print(f"{key} : {value}")

I have used this in my AI Agent script to filter records specific to user sites.

Here's the link to Git Repo.
https://github.com/sankargh/maximo_ai_1/blob/main/Architecture.md

0 comments
13 views

Permalink