Showing posts with label Object Launch Point. Show all posts
Showing posts with label Object Launch Point. Show all posts

Thursday, 30 June 2022

Maximo Attachment File Size

 Below is the script to calculate the Attachment size in Maximo. The File class is used to get the File details and Length() method is used to capture the size details.

from java.io import File 

path = mbo.getString("DOCLINKS.DOCINFO.URLNAME")
print("The Path Value:",path)
if (path):
	file =  File(path)
	print("The Size of the File in Bytes",file.length())
	print("The Size of the File in MB",file.length()/1024)
	print("The Size of the File in GB",file.length()/(1024 * 1024))
Below is the output captured in the system logs.
[6/30/22 8:01:53:951 EDT] 000000e2 SystemOut     O 30 Jun 2022 08:01:53:951 [INFO] [MXServer] [] ('The Path Value:', u'c:\\DOCLINKS\\ATTACHMENTS\\Maximo-access-via-Published-Service-in-your-local-laptop-browser.docx')
('The Size of the File in Bytes', 543667L)
('The Size of the File in MB', 530L)
('The Size of the File in GB', 0L)

Monday, 8 March 2021

Maximo Date Manipulation Using Automation Scripts

In this topic, we are going to see how to manipulate Maximo dates using Automation scripts. The different kinds of manipulation are

  1. Adding Number to the date
  2. Subtracting Number to the date
  3. Changing the format of the date
  4. Difference between two dates in days 

In the below examples we are going to use Python scripts in Maximo

  1. Object Launch Point is used
  2. Asset object
  3. The “INSTALLDATE” attribute is modified

  Java Calendar class is used for Date Manipulation.


1.     Adding Number to the date

Current date from MXServer is got and adding number (10) to that date.

print("**************Start of C_TEST ********************")
from java.util import Date
from java.util import Calendar
from psdi.server import MXServer

currentDate = MXServer.getMXServer().getDate()
cal = Calendar.getInstance()
cal.setTime(currentDate)

cal.add(Calendar.DATE, 10) 

print ("After Additional to Current Date ---> ",cal.getTime()) 

mbo.setValue("INSTALLDATE",cal.getTime()) 
print("**************End of C_TEST ********************")

Tuesday, 13 August 2019

Populating Condition Codes By Just Clicking Condition Code Check Box in Maximo

Recently we had a requirement to add the condition Code on clicking the Condition Code Check box in Item application.

Below is the Code that was written in JavaScript,
Launch Point Type: Attribute Launch Point
Object: Item
Attribute Name: CONDITIONENABLED

importPackage(Packages.psdi.mbo);

var conditioncode  = mbo.getBoolean("CONDITIONENABLED");
var itemconditionSet = mbo.getMboSet("ITEMCONDITION");

if(conditioncode)
{
  for(i=0;i<3;i++)
  {
    var itemcondition = itemconditionSet.addAtEnd();
    if(i == 0)
    {
      itemcondition.setValue("CONDITIONCODE","A");
    }
    else if(i == 1)
    {
      itemcondition.setValue("CONDITIONCODE","B");
    }
    else if(i == 2)
    {
      itemcondition.setValue("CONDITIONCODE","C");
    }
  }
}



Wednesday, 24 July 2019

Maximo Automation Script setting values while Initializing

There are times where we need to set the value when the object is invoked rather that setting the values during the save method. This can be achieved in Maximo automation scripts.

Step 1: Create an Object Launch Point with JavaScript.
Step 2: Make sure to check the Initialize? check box is checked. And all other check box are unchecked.
Step 3: Below is the sample code for setting the "Inspection Required" and "Adding Spare Parts" check box to always be checked when the item is created.

importPackage(Packages.psdi.mbo);
if(mbo.getString("ITEMSETID")=="ITEMSET1"){
    if(mbo.toBeAdded()==true){
        mbo.setValue("INSPECTIONREQUIRED", 1);
        mbo.setValue("SPAREPARTAUTOADD", 1);
    }
}