Generating Auto number values manually in Maximo / ICD

NOTE: Please see the updated post at https://maximomize.com/generating-auto-number-values-manually-in-maximo-icd

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 db query select ticketid from SR order by ticketid desc;

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.

Step 2. Write an automation script or a java class for it

Create an automation script for SR object with with the following properties.


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.

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

MboValue irseq = this.getMboValue("IRSEQ");
irseq.autoKey();
int id = this.getInt("IRSEQ");

9 thoughts on “Generating Auto number values manually in Maximo / ICD

  1. Hello Rana,
    The second screen shot that shows the automation script properties does not show the configuration of the automation script.
    Can you please help me understand the automation script configuration to do this task?

    Like

    1. I have updated the post. It can be either attribute or object launch point. Object launchpoint being more preferred in this case

      Like

  2. Why I have to use AutoKey, if I will use a script?
    just read the value, then set a new value with one increament

    Like

    1. Thats one way of doing this but autonumber will be a bit faster

      Like

  3. Hi Rana Ahmed,

    Great to know this from you.

    Actually when create PR LINES, in the PRLINENUM, maximo generates 1,2,3– with out any miss.
    Please respond on this.

    But sometimes user deleting 2nd PRLINE, after saving the record, I can see 1 and 3 only.

    If user delete any one record out of 3, I want the numbers in sequence 1,2. Not like 1,3(2nd prline deleted and saved, can se 1,3 only) and 2,3(1st prline deleted by user and saved, can see 2&3 PR lines only)
    Any suggestions on this. Or is your codes works for this scenario as well.

    Like

    1. It is meant for single row only.
      May be try the following

      MboRemote pr = …;
      MboSetRemote prlines = pr.getMboSet(“$sortedlines”, “PRLINE”, “prnum=:prnum and siteid=:siteid order by PRLINENUM asc”);
      MboSetEnumeration mse = new MboSetEnumeration(prlines);

      int counter = 0;
      while (mse.hasMoreElements()) {
      MboRemote line = mse.nextMbo();
      if (!line.toBeDeleted()) {
      if (line.getInt(“PRLINENUM”) != counter)
      line.setValue(“PRLINENUM”, counter, MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION);
      counter++;
      }
      }

      Like

  4. Hi Rana Ahmed,
    open TICKET object and add a persistent attribute IRSEQ in it. How entity can be SR as shown in image. Entity is showing TICKET in my case. Can you pls clear my doubt.

    Like

    1. Try to add it in TICKET table. then open SR object IRSEQ will be present in it as well with Entity of SR

      Like

      1. Hello again,
        Thanking you for reply. Yes, IRSEQ is showing in SR object with SR entity. But further facing problem in automation. Create script with SR object launch point and also place same source code in script but no change in SR TICKETID attribute. Do i need to change source code? where am i making mistake?
        Can you guide me little more…

        Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

search previous next tag category expand menu location phone mail time cart zoom edit close