Generating Auto number values manually in Maximo / ICD

Created
Nov 22, 2021 06:49 AM
Tags
java
automation script
Status
Completed
Created Date
Requirement
Recently I had a requirement in which the client wanted an ID field in their SR table which is in sequence. i.e. 1,2,3,4,5… and none of the sequence should be missing when they run a query in their db. They could not use TICKETID / TICKETUID as if the user clicks on new SR and then clicks cancel, the sequence is updated but not not saved in db. Hence, missing numbers in sequence upon a database query select ticketid from SR order by ticketid desc

Procedure

There is a simple method to generate sequence numbers on update only
Step 1: Add an attribute in Database and attach a sequence to it
In database config app, open TICKET object and add a persistent attribute IRSEQ in it. Check the Can Autonumber checkbox. Then in the autonumber field write any value for autonumber e.g. IRSEQ. Maximo will says this autonumber does not exist and should it create it. Click yes. Turn on Admin mode and apply changes.
notion image
Step 2. Write an automation script or a java class for it
Create an automation script for SR object with with the following properties.
notion image
Add the following in source code of script.
ireseq = mbo.getMboValue("IRSEQ");
ireseq.autoKey();
id = mbo.getString("IRSEQ"); // id will be the incremented field
Now whenever a new SR is submitted either via service portal or ICD / Maximo. This value will be incremented in sequence.
The above script can be used with attribute or object launchpoint or anywhere where you want the autonumber to be incremented.
notion image
Optional do the same in Java
The same can be done in Java. Considering you have already attached class to SR object. Add the follwing Java code to genreate next value for a sequence
Value irseq = this.getMboValue("IRSEQ");
irseq.autoKey();
int id = this.getInt("IRSEQ");