Maximo List Archive

This is an archive of the Maximo Yahoo Community. The content of this pages may be a sometimes obsolete so please check post dates.
Thanks to the community owner Christopher Wanko for providing the content.



Maximo 7.6 Automation Script help

From: holli.parris (2016-03-11 07:31)

First I am not a java programmer but I need some help with some automation scripts. I have a simple launch point automation script that does some calculations. I need to add an error message to the script that won't allow them to change or add if the calculation is less than 0. Right now I have the script in Javascript.
TOTISSUE = TOTISSUE - OLDQTY
OLDQTY = ISSUEQTY
TOTISSUE = TOTISSUE + ISSUEQTY
REMQTY = ORIGQTY - TOTISSUE
Can someone help me set this up so that it will error before running the script and not allow a save if the TOTISSUE > REMQTY.


From: InComm Solutions Inc. (2016-03-11 08:07)

The slick way to do it is to add a message into the Maxmessages table, then
call the message from the autoscript.

To add the message into the Maxmessages table, go into DBConfig / Select
Action / Messages. Take note of the Message Group and Message Key that you
enter when you're putting it in.

In the autoscript, usage is simple - you just add this code:
Errorkey = {message key}
Errorgroup = {message group}

If you're doing autoscripting, I would suggest having this document on hand
for reference:

https://www.google.com/url?sa=t
<https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uac
t=8&ved=0ahUKEwj17YXy_7jLAhVMzGMKHcwCCB0QFggjMAA&url=https%3A%2F%2Fwww.ibm.c
om%2Fdeveloperworks%2Fcommunity%2Fforums%2Fajax%2Fdownload%2F77777777-0000-0
000-0000-000014772567%2Fb8ec7d85-6a8d-4e25-bb89-d729c3322406%2Fattachment_14
772567_Scripting_with_Maximo.pdf&usg=AFQjCNHe2rZPbwkpWpniZ05cip3_LpfSCA>
&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwj17YXy_7jLAhVMzGM
KHcwCCB0QFggjMAA&url=https%3A%2F%2Fwww.ibm.com%2Fdeveloperworks%2Fcommunity%
2Fforums%2Fajax%2Fdownload%2F77777777-0000-0000-0000-000014772567%2Fb8ec7d85
-6a8d-4e25-bb89-d729c3322406%2Fattachment_14772567_Scripting_with_Maximo.pdf
&usg=AFQjCNHe2rZPbwkpWpniZ05cip3_LpfSCA


From: MAXIMO@yahoogroups.com [mailto:MAXIMO@yahoogroups.com]
Sent: Friday, March 11, 2016 7:32 AM
To: MAXIMO@yahoogroups.com
Subject: [MAXIMO List] Maximo 7.6 Automation Script help


First I am not a java programmer but I need some help with some automation
scripts. I have a simple launch point automation script that does some
calculations. I need to add an error message to the script that won't allow
them to change or add if the calculation is less than 0. Right now I have
the script in Javascript.
TOTISSUE = TOTISSUE - OLDQTY
OLDQTY = ISSUEQTY
TOTISSUE = TOTISSUE + ISSUEQTY
REMQTY = ORIGQTY - TOTISSUE
Can someone help me set this up so that it will error before running the
script and not allow a save if the TOTISSUE > REMQTY.


From: holli.parris (2016-03-11 10:29)

Thank you!
So would this be the script?
if issueqty > REMQTY:
errorgroup = "something"
errorkey="else"
else:
TOTISSUE = TOTISSUE - OLDQTY
OLDQTY = ISSUEQTY
TOTISSUE = TOTISSUE + ISSUEQTY
REMQTY = ORIGQTY - TOTISSUE


From: holli.parris (2016-03-11 13:27)

So the following script brings up the error on the quantity but when the quantity is less than remaining qty I get the following error:
BMXAA7837E - An error occured that prevented the ISSUEADD script for the ISSUEADD launch point from running. TypeError: unsupported operand type(s) for -: 'float' and 'NoneType' in <script> at line number 5
Script is (python):
if ISSUEQTY > REMQTY:
errorgroup = "TINS"
errorkey="TINQTY"
else:
TOTISSUE = TOTISSUE - OLDQTY
OLDQTY = ISSUEQTY
TOTISSUE = TOTISSUE + ISSUEQTY
REMQTY = ORIGQTY - TOTISSUE
In some cases the REMQTY could be null, but it wasn't in this case. So how do I deal with null values and why did I get the error above when remaining qty was not null.


From: Chris Lawless (2016-03-11 17:16)

Are you sure your variables are mapped correctly? As you say it seems one is null, either because it is truly null or isn't being passed correctly. Personally I don't like using variables, I prefer to get the value from the mbo within the script.
On March 11, 2016 at 4:27:38 PM EST, holli.parris@urs.com [MAXIMO] <MAXIMO@yahoogroups.com> wrote:   So the following script brings up the error on the quantity but when the quantity is less than remaining qty I get the following error: BMXAA7837E - An error occured that prevented the ISSUEADD script for the ISSUEADD launch point from running. TypeError: unsupported operand type(s) for -: 'float' and 'NoneType' in <script> at line number 5 Script is (python): if ISSUEQTY > REMQTY: errorgroup = "TINS" errorkey="TINQTY" else: TOTISSUE = TOTISSUE - OLDQTY OLDQTY = ISSUEQTY TOTISSUE = TOTISSUE + ISSUEQTY REMQTY = ORIGQTY - TOTISSUE In some cases the REMQTY could be null, but it wasn't in this case. So how do I deal with null values and why did I get the error above when remaining qty was not null.