Thursday, August 21, 2014

Maximo Automation Script to concatenate two fields in one.

To create an automation script in Maximo that conbines two fields into a new field and is triggered by the change of one of the fields.

I have two fields in my application and want to combine those fields into one new field. 

One field on the record contains a project number and the other field contains a number unique for that project. The unique identifier for the record should be the project number + number.


The concatenated number will be stored as my IssueID.

I created three fields in Database Configuration
  • Number used for IssueID  (GMBISSNUM - INTEGER 12)
    • This is a number that increases and will only be unique per Project.
  • Issue ID (GMBISSUEID - UPPER - 20)
    • This will be the concatenated ID (Project + Number)
  • Project (GMBPROJECT - UPPER - 10)
    • A workorder number.
I have put the fields on screen like you can see below:

Next I create the Script. Go to the Automation Script application and choose in the Select Action menu for Cerate -> Script with Attribute Launch Point

In the first step, fill in a name for 'Launch Point', a 'Description', check if the 'Active?' checkbox is set, I choose 'SR' as the Object and want the script to run if the Attribute 'GMBPROJECT' is changed.

Click [Next] to go to step 2

In step 2 fill in a Name for the Script, a Description, check if the Script Language is set to 'jython'.

Click [Next]  to go to the next step.

Here we will put the following script in the 'Source Code' field:

import java;
import sys;
from psdi.mbo import Mbo;
from psdi.mbo import MboSet;
from psdi.server import MXServer;

myMxServer = MXServer.getMXServer();

#mbo is the current mbo from where the script is run.

myProjectIssueSet = myMxServer.getMboSet("SR", myMxServer.getSystemUserInfo())
wherestring = "gmbproject = '" + mbo.getString("GMBPROJECT") +"'"

count = myProjectIssueSet.count();

#Determine if there is a number for the project.
if count > 0:
  #there are records, so there are numbers. Put them in an array
  issueNumbers = [];
  for i in range(count):
    myProjectIssue = myProjectIssueSet.getMbo(i);
    i += 1;

  #take the highest number from the array and increase it by one.
  highNumber = max(issueNumbers);
  highNumber2 = int(highNumber) + 1;
  GMBISSNUM = str(highNumber2);

#There is no existing number for this project.  
  #this is the first issue for this project. So start with number 1
  GMBISSNUM = '1';

#Generate the IssueID from the Projectnumber and the Issuenumber for the selected project.  


Click [Create]  to create the launch point and script.

The following message will pop-up (BMXAA7989I - The launch point was created successfully.)

Click [Close]

In the List the created script appears, click on it to open it and go to the 'Variables' tab. We need to create three variables here:

Variable:            GMBISSNUM
Variable Type:   INOUT
Override?:          checked
Binding Type:    ATTRIBUTE

Variable:            GMBISSUEID
Variable Type:   OUT
Override?:          checked
Binding Type:    ATTRIBUTE

Variable:            GMBPROJECT
Variable Type:   IN
Override?:          checked
Binding Type:    ATTRIBUTE

Click the 'Save' Icon in the top to save out work.

Next go to the Launch Points tab and click on 'Edit Launch Point Detail' icon in front of the Launch Point name.

Fill in the 'Binding Variables' for the variables on the Launchpoint. This will link the variable used in the script to the attribute in the Maximo database.

Click [OK] and Save the Script.

We go to the Application and create a new record.
Now when we fill in the 'Project' field the Number used for IssueID and the Issue ID fields are filled in by the script.

In this example the 'Number used for IssueID' is unique per Project. So the number 4 will only appear once for project 1002. It can however appear again for project 1003. This logic is also done in the script.


Monday, August 4, 2014

Hyperlink to explorer with variable

Create a link in Maximo to a file stored on a network drive. 

I want to create a link to a folder or a file from a Maximo screen. When the user clicks on the link the file should open with the on the user his device configured application.
When it is a folder, the folder should open in explorer.

The link should be dynamic and be build up from a static part and a variable part.


I use a Windows 2012 server with Maximo on a Oracle 11g Database in this example.

Note: This solution will only work on devices with a explorer.exe. So I gues only Windows based machines.

First I will create an extra field on the workorder application named GNZ_FILETEST with the following properties.

Save, Turn the Admin mode on, and then Apply the Configuration changes

When the configuration is done, turn off the admin mode and open the Application Designer. In the Application Designer, open the WOTRACK application as I will display this field on the workorder screen.

On the Main tab of the workorder screen I will add an textbox and a just below the textbox a Hyperlink.

Set the following properties for the textbox:
 - Attribute: GNZ_FILETEST

The for the hyperlink control, I set the following properties:

 - Label: Open Folder or File
 - Event Type:  launchexternal
 - Event Value: explorer.exe e:\\{GNZ_FILETEST}

I Use a local file path in order to test this, I will add the code for a link to a network drive further below in this post.

Save the application and open the Work Order Tracking application in Maximo.

Open an existing Workorder or create a new one. On the workorder tab you will now see the following:

In order to test this I will fill in 'DataPump' in the new text field, save the records and the click on the hyperlink.

Hmmmm nothing happens...

Let's see what's wrong.

I found this page online:

They mention: You may have to change the Activex settings in the Intranet zone to enable ""ActiveX Controls not marked as safe"

So I go and check that setting. I run Internet Explorer 10 in this example, so it may look different for you when you are using an other browser.

I go to Internet Options -> Security Tab, and for the 'Trusted Sites' (where my Maximo website is part of) I click on the 'Custom level' button

Then I scroll down to 'Initialize and script ActiveX controls not marked as safe for scripting'
There I set the radiobutton from disable to enable.

Click [OK] and then [Apply] and the [OK] again to close the Internet Options.

Now I close my browser and open it again and login to Maximo to go to the Work Order Tracking application. There I open the workorder again and click the link.

And now the explorer opens in the e:\DataPump folder :)

Afbeelding 11

You can choose not to use the variable GNZ_FILETEST, but I used it in this example so you could use if to make it more dynamic.

There are now some variations you can do in the Event Value.
Some options:

Connect to a network drive:
explorer.exe \\\\filesvr01\\Shared_folder_Name\\{GNZ_FILETEST}
Mind the double slashes here!

Open a file from a network drive, where the filename is specified in the textfield and the filetype is fixed:
explorer.exe \\\\filesvr01\\Shared_folder_Name\\{GNZ_FILETEST}.pdf

The explorer will take care of opening the default set pdf reader on the desktop. 


Friday, August 1, 2014

How to start with Windows (Phone) development

Create an App for my Windows Phone and/or Windows 8 desktop

I have no idea how to do this :)

I have basic programming skills in PHP, Object Pascal, Java and now a fair bit of SQL. I gues I need to learn a Microsoft Language


Step one - Installing the Tools.

I want to use C# (C-sharp) as the language to program in because I have used Visual Studio before and follwed some basic lessons for C#. Those lessons can be found here

So now in order to develop Windows Apps I need to get Visual Studio. I decide I want to get a free version so I go for Visual Studio Express. There are two different versions;

  • Visual Studio Express 2013 for Windows 
  • Visual Studio Express 2013 for Web

Here you can download the different versions:

I downloaded Visual Studio Express 2013 for Windows to develop my Apps in. 

For the C# lessons I needed to use the 'for Web' version.

When installing this version of Visual Studio note that you need Windows 8.1 !!

Here are the system requirements

Supported operating systems
  • Windows 8.1 (x86 and x64)
Hardware requirements
  • 1.6 GHz or faster processor
  • 1 GB of RAM (1.5 GB if running on a virtual machine)
  • 11 GB of available hard disk space
  • 5400 RPM hard drive
  • DirectX 9-capable video card running at 1024 x 768 or higher display resolution
Additional requirements
  • KB2883200 (available through Windows Update) is required
  • For Windows Phone development:
    • Windows Phone 8.0 development requires Windows 8.1 (x64) or higher
    • Windows Phone 8.1 development requires Windows 8.1 (x86) or higher
    • For the Windows Phone emulators, Windows 8.1 (x64) Professional edition or higher, and a processor that supports Client Hyper-V and Second Level Address Translation (SLAT)
    If your computer meets the operating system requirements but does not meet the hardware requirements for the Windows Phone Emulators, the Windows Phone development tools will install and run. However, the Windows Phone 8.0 and 8.1 Emulators will not function and you must use a device to deploy or test Windows Phone apps.

Another thing worth noting is that your development station needs Hyper-V. Without Hyper-V you cannot start the Phone Emulator and testing can then only be done on a connect Windows Phone device. Which is something you don't want because you then cannot test different resolutions, gps etc etc.

I didn't know if my laptop had Hyper-V so I decided to go in to the BIOS. I have a Sony Vaio Duo 11 and it took me a little while to figure out how to get in. I tried F2, F8 , F10 etc but then I found out that I had to press the 'ASSIST' button while the laptop was shut down.

Shut down the Vaio

Click the 'ASSIST' button at the front bottom.

Go to the BIOS (F2)

Go to the 'Advanced' tab and [Enable] the 'Inter(R) Virtualization Technology'

So this was specific for the Sony Vaio. You will need to figure it out for your own laptop/desktop :)

Step two - Lessons

Now for some lessons I decided to go back to the site with the C# lessons. And it appears they also have some nice lessons on Windows Phone 8.

I started with the Windows Phone 8 Development for Absolute Beginners:

And half way in I found this serie:
A Windows Phone 8.1 series and I decides to check that one out and follow the lessons.

Next step is to design and create my very own app. I am currently in the process of doing so and  I'll keep you posted and share my experiences and problems.