Thursday 6 February 2020

RUN A SCRIPT INTERACTIVELY FROM ICD/MAXIMO




The Automation Script application provides the capability to directly run a script without having a launch point defined. This is useful to test some scripting capabilities or to run scripts performing maintenance tasks triggered by an user.
AttentionIf you are using Maximo or ICD in Version 7.6.x you might not find the “Launch Script” Action. In that case you should read this article to solve this issue first!
To test this behavior we will create a simple script without a launch point which lists all defined users from the ICD/Maximo system. Important is, that in this scenario no implicit variables are available and you have to initialize your MBO context manually based on the MXServer object. The scripts looks as follows:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#DESCRIPTION:Script to demonstrate usage of Run-Script function from GUI
from psdi.server import MXServer
from psdi.iface.mic import MicService
mxServer = MXServer.getMXServer()
micService = MicService(mxServer)
micService.init()
userInfo = micService.getNewUserInfo()
# Example: Loop over all Users....
userSet = mxServer.getMboSet('MAXUSER', userInfo)
userMbo = userSet.moveFirst()
while (userMbo != None):  
    print "User ",userMbo.getString("USERID")   
    userMbo = userSet.moveNext()
To run the script you should hit the following icon in the Taskbar of the Automation Script application:
Selection_042
The result should look as follows:
Selection_043

  • list only active users ..you can add this
    # Example: Loop over all Users….
    userSet = mxServer.getMboSet(‘MAXUSER’, userInfo)
    #— list only active users add SQL where ————–
    userSet.setWhere (“STATUS = ‘ACTIVE'”)
    # – Run SQL filter
    userSet.reset()

Maximo 76 Scripting Features guide

Maximo 76 Scripting Features guide is a great source of information but it has been released only in PDF format so it’s poorly indexed by Google

A Scripting Solution to Set Child Work Order Values From the Parent

A Scripting Solution to Set Child Work Order Values From the Parent

Body

Introduction
Crossover domains can be a convenient way to copy values from a parent work order to a new child when adding a child work order. In most cases this works without a problem. However, if the values being copied from parent to child include ASSETNUM, LOCATION, and/or GLACCOUNT, the crossover domain may not work as expected. This is the case if these values do not match, for example, if the ASSETNUM does not reside at the location specified by LOCATION, or if the GLACCOUNT does not match the ASSETNUM/LOCATION combination.
This post describes a technical solution for overcoming the problems that arise from using a crossover domain to copy ASSETNUM, LOCATION and/or GLACCOUNT values from a parent to a child work order when the 'New Row' is clicked on the work order's 'Children of Work Order nnnn' table window. The solution employs Maximo Automation Scripting.

Disclaimer
Before we get into the details please note that this solution should not be deployed directly into a production environment before testing and making sure your individual business case is met. You may need to modify the script to meet your own specific needs. The references provided at the end of this post will be helpful in the event that you need to modify the script or if you would like to further pursue automation scripting to customize your environment.

Overview
ASSETNUM, LOCATION, and/or GLACCOUNT mismatches are permitted when work orders are entered via a non-UI mechanism, or in the UI when the user responds 'No' to any of the following dialogs:
image
image

image

These mismatches are not a problem if this is what is desired on the parent record.

Problem
The problem arises when a user adds a child work order to a parent that does not have matching ASSETNUM, LOCATION, and/or GLACCOUNT values and a customized crossover domain attempts to cross these values over to the new child. One of the above dialogs will be raised when 'New Row' is clicked. When the user responds to the Yes/No/Cancel dialog, a second record is added due to the way that Yes/No/Cancel dialogs work, resulting in two incomplete child records. As a result, the error "BMXAA4195E - The Duration field requires a value" occurs when attempting to save the new child. This error is misleading because in the UI, the Duration field is clearly populated:
image
The error is coming from the second child that was erroneously added as a result of the response to the Yes/No/Cancel dialog. This second record does not appear in the UI.

Solution Using an Automation Script
This problem can be avoided by using the TPAE automation scripting functionality instead of the crossover domain. The reason for this is that in the script one can avoid the raising of the Yes/No/Cancel dialog when ASSETNUM, LOCATION, and/or GLACCOUNT is set.
The following steps explain how to copy parent work order values (ASSETNUM, LOCATION, and GLACCOUNT) to the child when the child is being added:
Go to System Configuration > Platform Configuration > Automation Scripts.

1. Create > Script with Attribute Launch Point.
image
Click 'Next'.

2. Specify the script name and scripting language.
image
Click 'Next'.

3. Create the script:
image
.
#*************Script Text******************
from psdi.mbo import MboConstants

wo = mbo.getOwner()

if onadd and wo is not None and not mbo.isNull("parent"):
    mbo.setValue("location",wo.getString("location"),MboConstants.NOVALIDATION)
    mbo.setValue("assetnum",wo.getString("assetnum"),MboConstants.NOVALIDATION)
    mbo.setValue("glaccount", wo.getString("glaccount"),MboConstants.NOVALIDATION)
#********************************************
The key to the automation script working is to specify MboConstants.NOVALIDATION when setting the values. This is not possible with crossover domain functionality.

BFI-9.2.11.0 & ICD-7.6.1 with ITIC 7.6.1

Steps to create a BigFix to ICD hardware mapping:
  1. Create, and test the connection to, a data source using the IBM BigFix Data Schema, with an IBM Endpoint Manager and SUA API Connection Method (I named it BFP, for BigFix Platform).
  2. Create, and test the connection to, a data source using the Deployed Assets 7.x Data Schema, with the appropriate JDBC Driver Connection Method (I named it DPA, for DePloyed Assets).
  3. Create an empty mapping (I named it BF-HW2DPA) with a source of BFP and a target of DPA, and import the IEM90ToDPA75.fsn mapping file. It has a file date of 14 Sep 2017 and a time of 17:20. Click on Select Action, Show Errors. This should result in no errors found. Next, Select Action, Save.
Steps to create a BFI to ICD Software Mapping
  1. Create, and test the connection to, a data source using the IBM BigFix Inventory Data Schema, with an IBM Endpoint Manager and SUA API Connection Method (I named it BFI, for BigFix Inventory).
  2. Create an empty mapping (I named the mapping BF-SW2DPA) with a source of BFI and a target of DPA, and import the BigFixInventoryToDPA75.fsn mapping file. It has a file date of 14 Sep 2017 and a time of 17:20. (Do not use the mapping file BigFixInventory2x__90ToDPA75.fsn) Click on Select Action, Show Errors. This should result in no errors found. Next, Select Action, Save.
This should result in a set of mappings that will run from the command line.

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...