Skip to main content

Handle SQL Condition on Workflow Action’s in Maximo via OSLC API

 Maximo’s NextGenREST OSLC API(s) are very powerful but they don’t provide the capability to handle SQL Conditions associated with Actions or Nodes. For example- A manual Input node in the workflow can have multiple actions available and they are to be shown on the basis of SQL Expressions then OSLC API returns all options when making API call w/o evaluating the SQL expression.

To handle this, another feature to call automation script using OSLC API can be used to return the response with a flag having true or false information. In the script below, let us assume we have a workflow on the PR object and we need to evaluate SQL conditions associated with a manual input node.

From Postman make a GET call for each action:

GET <servername:port>/maximo/oslc/script/<scriptname>?ownerid<x>&actionid=<y>&wfactionid=<z>

& response of this script shall return true or false based on SQL condition evalauted.

load("nashorn:mozilla_compat.js"); importClass(Packages.psdi.server.MXServer);
importClass(Packages.psdi.common.parse.ParserService);
importClass(Packages.psdi.mbo.SqlFormat);
// Pass ownerid, actionid and wfactionid from OSLC API Call as Query parametervar response = {};
var responseBody;
var prid = request.getQueryParam("ownerid");
var actionid= request.getQueryParam("actionid");
var wfactionid= request.getQueryParam("wfactionid");
var userInfo = MXServer.getMXServer().getSystemUserInfo();
var sqf = new SqlFormat(userInfo, "actionid=:1 and wfactionid=:2 ");
sqf.setObject(1, "WFACTION", "actionid", actionid);
sqf.setObject(2, "WFACTION", "wfactionid", wfactionid);
var wfactionSet = MXServer.getMXServer().getMboSet("WFACTION", userInfo);
wfactionSet.setWhere(sqf.format());
wfactionSet.reset();
var wfactionMbo = wfactionSet.getMbo(0)
var sql=wfactionMbo.getString("condition")
if(sql.length>0)
{
var sqf1 = new SqlFormat(userInfo, "prid=:1"); sqf1.setObject(1, "PR", "prid", prid);
var prSet = MXServer.getMXServer().getMboSet("PR", userInfo); prSet.setWhere(sqf1.format());
prSet.reset();
if(prSet.isEmpty())
{
response.available=true;
}
else
{
var prMbo = prSet.getMbo(0)
// Call Parser Service method to pass the SQL Condition and MBO to get the true or false after SQL Condition is evalauted.var parServ=MXServer.getMXServer().lookup("PARSER");
var avalbl = parServ.getBoolean(sql,prMbo);
// Add variable available in response object and set it to boolean returned when there is SQL associated.
response.available=avalbl;
}
}
//Return the API response in form of JSON String
responseBody = JSON.stringify(response);

Comments

Popular posts from this blog

Maximo OSLC Integration with External System- Get data in JSON format

Greetings! If you have noticed recent version of Maximo, couple new application in Integration module has been added which are OSLC Resources and OSLC Provider.These modules gives us ability to integrate with external system in JSON. OSLC is an open community that creates specifications for the integration of products and/or tools.  IBM is a leading contributor to this community and many software products within the IBM Software Group are implementing OSLC in order to enable cross-product integrations. An OSLC integration requires 2 players-  1. OSLC Consumer application 2. OSLC Provider application.   An OSLC provider application makes containers of associated resources(data) available for integration through service providers. Consumer applications then use these service providers to query resources and to create, update, and delete resource data.  The consumer application sends a query to the service provider for resource data. The service p...

Power of Maximo Formulas - Build logic w/o Custom Java code or Automation Script

Greetings! Maximo 7.6 has lot of additional capabilities added in Tivoli Automation Engine as compared to older versions of Maximo which aim to allow users to make change in applications for small requirements without actually going to customization route. Automation scripts is one of such tool given for users and technical developers to change the behavior of Maximo in case where functionalities can't be changed only via use of configuration. If we have a requirement to populate some field on basis of other fields , we can easily do that with automation script but in order to do that you still need to have knowledge of Jython or Javascript to write the logic. Maximo formula is one the tool given by IBM which can be used for such business requirements and user can make changes to Maximo logic via configuration without getting into difficulties of coding. Formulas are available from Maximo version 7603. With release of Maximo version 7606, there has been addition of new capabil...

Call publish channel w/o enabling Event Listener in Maximo

Greetings! Generally if we have to send data to external system via MIF, we create Publish Channel and enable Event Listener on publish channel. Once event listener is enabled, Maximo listens for event and send data to end point via publish channel for each Save of related MBO . But t here are many scenarios where we need to send data to external system using publish channel on specific event and not for every save. In order  to send to external system on specific event, for example - sent data to Ariba when PO status in Maximo is changed to APPR, we can use automation script or java code to call publish channel on the go. Below code can be used in automation script - server = MXServer.getMXServer() userInfo = mbo.getUserInfo() whereClause = <CONDITION> server.lookup("MIC").exportData("<Publish Channel Name>", "<External System Name>", whereClause, userInfo, 1000) Via Java class - MXServer server = MXServer.getMXServer(); ...