1

I have a work order in Maximo. The work order application has custom fields:

FieldA = 'Hello'

FieldB

I want to take the value from FieldA and pass it to a function in the Oracle database:

CREATE OR REPLACE function hello_world(var1 in varchar2) return varchar2  
    is
        hw varchar2(15);
    begin
        if var1 = 'Hello'  then 
            hw := var1 || ', World!';
        end if;
        return hw;
    end;
/

And I want FieldB to display the value that was returned by the function:

FieldB = hello_world(FieldA) >>> Hello, World!

How can I do this?

(Version 7.6.1.1; desktop/classic)

User1974
  • 276
  • 1
  • 17
  • 63

1 Answers1

2

I would create an Automation Script with an Attribute Launch Point on FieldA. The script will have to use a reference to the database manager and the user's connection key to connect directly to the database, and then use some standard java.sql calls to create a statement, execute it, and extract the results. Then it would put the results in FieldB.

To do all that, it will help to have the Maximo business objects JavaDocs and the Java 8 JavaDocs on hand, on top of the Automation Scripting help available from within Maximo.

If you need someone to do that coding for you, I suggest hiring a consultant. :-)

And all that said, you should just use the automation script to do what you have the database function doing, if at all possible. To be more blunt, what you are wanting to do is not considered good practice. So, make sure to include in your script's comments your justification for not following good practice.

Preacher
  • 2,127
  • 1
  • 11
  • 25
  • Thanks for your answer! Can you explain a bit more about why it is a *'bad practice'*? Is it a security thing? A complexity thing? Something else? – User1974 Jun 17 '19 at 17:35
  • @user1973, the short answer is that you should be consistent with how your COTS (Commercial, Off The Shelf) software works. If you want a longer answer, I suggest asking another [tag:maximo] Question. – Preacher Jun 17 '19 at 18:31
  • Ok. Thanks. I've posted a separate question, as you suggested: [Populating a Maximo field using a db function: Why is this a bad practice?](https://stackoverflow.com/questions/56637330/populating-a-maximo-field-using-a-db-function-why-is-this-a-bad-practice) – User1974 Jun 17 '19 at 19:02
  • 1
    A variation on this answer would be to create a script with no launch points that will pass the passed in value `params[0]` to your database function and return the output in the `evalresult` outbound implicit variable, then in Database Configuration create a Formula Function that calls your script and call that Forumula Function from an Attribute Formula. Of course, you can skip the DB function call if your script can just do the calculation itself. – Preacher Jul 24 '19 at 18:07