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.
I have a simple "action" automation script that's adds (1) to the existing value in LOCATIONS.LR_CYCLECOUNT attribute when a push button is pressed. This is working great, but I am hoping that someone can help me add (1) to not only the record I am currently on, but also to all of the children of that location?
Here is the current automation script (javascript)
newcount=(oldcount)+1
newlifecount=(oldlifecount)+1
We do not want to use meters for a number of reasons and simply want to increment an attribute.
Many thanks in advance.
Mike
Mike,
The first thing you need to do is to create a relationship that will return
all of the child records that you are interested in, with this in place it
is then a matter of navigating that relationship to create a set of the
children and looping through them to increment your target value on each
record.
I can't promise the syntax is going to be correct as email doesn't do a lot
of jython validation but consider this pseudocode as a starting point.
myChildLocs = mbo.getMboSet("RELATIONSHIPNAME")
childCount=myChildLocs .count()
if childCount>0 :
for i in range(childCount):
myChildLoc=myChildLocs.getMbo(i)
myVal = myChildLoc.getInt("myField")+1
myChildLoc.setValue("myField",myVal)
There is a lot of debate over how automation scripts clean up after
themselves, the theory is that upon completion Maximo will close and save
all child mbo Sets then do the same for the parent (mbo) - as such you
should no include close() or save() calls in your script.
Chris.
On Tue, Nov 4, 2014 at 5:27 AM, mlevinson@ledgesoft.com [MAXIMO] <
MAXIMO@yahoogroups.com> wrote:
>
>
> I have a simple "action" automation script that's adds (1) to the existing
> value in LOCATIONS.LR_CYCLECOUNT attribute when a push button is pressed.
> This is working great, but I am hoping that someone can help me add (1) to
> not only the record I am currently on, but also to all of the children of
> that location?
>
> Here is the current automation script (javascript)
>
> newcount=(oldcount)+1
> newlifecount=(oldlifecount)+1
>
> We do not want to use meters for a number of reasons and simply want to
> increment an attribute.
>
> Many thanks in advance.
>
> Mike
>
>
>
>
>
>
>
Hi Mike,
It looks like you'll need to get into some actual scripting..
You'll need to get a relationship to LOCANCESTOR for where :location = ancestor and :location != location and :siteid = siteid and systemid = 'PRIMARY' (or whatever location system / hierarchy you're wanting to use to identify children). Then, you can iterate over the results. (You could look in DB Config and see if there's already a relationship like this there.)
Rather than continuing to give you fish, here's how to fish...
1. Go get yourself a copy of the Maximo API documentation (https://www.ibm.com/software/brandcatalog/ismlibrary/details?catalog.label=1TW10MA1Z).
2. Look up the psdi.mbo.Mbo.getMboSet(), getInt() and setValue() methods. (The "mbo" implicit variable is an instance of psdi.mbo.Mbo.)
3. Look up the psdi.mbo.MboSet.moveFirst() and .moveNext() methods.
4. Go to http://www.jython.org/jythonbook/en/1.0/index.html#part-i-jython-basics-learning-the-language http://www.jython.org/jythonbook/en/1.0/index.html#part-i-jython-basics-learning-the-language and learn about Iteration using the while loop. (Don't learn about Jython libraries, because you don't have access to them.)
If you need more help, look me up.
Best regards,
Jason Uppenborn
http://ca.linkedin.com/in/jasonuppenborn/ http://ca.linkedin.com/in/jasonuppenborn/