IBM Support

Automation Script for Maximo Integration Framework (MIF)

Technical Blog Post


Abstract

Automation Script for Maximo Integration Framework (MIF)

Body

Automation Script for Maximo Integration Framework (MIF) is introduced in 7.6 and is a good practice to create and manipulate data. You have the same functionality as the Java Class. But in this case you are not going to lose your class if you upgrade Maximo.

Let’s take a look at a simple example.

Creating an Automation Script for an inbound Object Structure

  1. Go to System Configuration =>  Platform Configuration => Automation Scripts.
  2. Click on Select Action => Create => Script for Integration.
  3. You have a couple options now. We are not going to cover all options now, but in the near future.
    1. Select Object Struture
    2. On Object Structure field we are going to create an example using ITEM. Fill in with MXITEM
    3. Select Inbound Pocessing
    4. Select Javascript as a Script Language

image

 

  1. Copy and paste the following code on Source Code. This code just checks if the commodity group of the item is ELEC. If yes, it will fill in the description with the word ELECTRICAL ITEM.

importPackage(Packages.psdi.server);
importPackage(Packages.psdi.mbo);

function beforeMboData(ctx)
{
       mboSet = ctx.getMboSet();
      if(ctx.isPrimary())
      {
               mbo = mboSet.moveFirst();
              if(mbo==null)
                  {
                        return;
                  }
              else
              {
                  var comodity = mbo.getString("COMMODITYGROUP");
                 if(comodity == "ELEC")
                 {
                      mbo.setValue("DESCRIPTION","ELECTRICAL ITEM");
                  }
              }
          ctx.setMbo(mbo);
          ctx.setMboSet(mbo.getThisMboSet());
    }
}

  1. Click on Create button.

 

Done, the automation is ready to work.

I created a Web Service using the Object Structure MXITEM and sent the xml below:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:max="http://www.ibm.com/maximo"&gt;

   <soapenv:Header/>

   <soapenv:Body>

      <max:SyncMXITEM>

         <max:MXITEMSet>

            <max:ITEM action="AddChange">

               <max:COMMODITYGROUP>ELEC</max:COMMODITYGROUP>

               <max:ITEMNUM>PF1002</max:ITEMNUM>

               <max:ITEMSETID>SET1</max:ITEMSETID>

            </max:ITEM>

         </max:MXITEMSet>

      </max:SyncMXITEM>

   </soapenv:Body>

</soapenv:Envelope>

 

This is the result:

image

 

Now let’s understand my Javascript code.

I am using the function beforeMboData(ctx), this function already exists on Maximo framework .  The beforeMboData(ctx) function is available when the Maximo business object is created but before the values in the business object are set by the integration framework. Processing of the object structure can change the setting of business object data. Processing can also set flags on the fields, such as the samevaluevalidation flag, which triggers field validations even when the field value is set with the current value of the field.

You can find all functions on the link below:
http://www.ibm.com/support/knowledgecenter/SSLKT6_7.6.0/com.ibm.mif.doc/mif_scripting/r_in_functions.html?lang=en

The others methods and the rest of the code, if you already created a Java code for Maximo you will recognize.

TIP: If you need DEBUG your code use the command print. For example:
print(“Test command print”);
This command will print the string on the Systemout log, this is a way to see values of a variable for example.

 

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSLKT6","label":"IBM Maximo Asset Management"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

UID

ibm11131279