Abdelrhaman,
OK I see why you are trying to do here now (I think.... π€). The challenge you are facing is a timing issue. It is entirely possible to create a location and save it without ever tying it to a system or a hierarchy. When that occurs you are automatically faced with a business logic challenge. What to do with a saved location valued (that you CANNOT change) when then subsequently tying it to a hierarchy (which by definition belongs to a system.). If we make a couple of assumptions and encode those in some business rules you can work around this issue. First is that you hierarchy that you are working with is the
Primary hierarchy (which is "normally" a geo-based one, as opposed to a "system" based one like air, water, electric, etc.).
Many organisations have a "smart" primary location hierarchy and desire to ensure that children assigned to this location hierarchy follow a naming standard. I believe you are trying to automate that (and perhaps using a series of domains based on location "type", generate the location value on save?) If that is all correct then an attribute or object automation script might work. Not sure which one might work better, I have limited experience between the two. Perhaps
@Steven Shull could chime in to clarify which might work better. Further, when you create the location value you have to manually associate the system(s) to the location and that is a separate action, distinct from the act of associating parents and children to create the hierarchy.
Also what is interesting to note is that you are trying to set the LOCHIERARCHY parent value from a custom attribute. This is technically an override of the MBO set value that occurs when you create the parent-child relationship. Normal action is to set this value based on the location you are on when you set the child relationship through the UI. So if the Parent value is not the same as the parent's LOCATION value, you technically break the parent child chain. Keep in mind the mbo also inserts records into the LOCANCESTOR object. So, depending on how far down the hierarchy your child is you can see anywhere from two to two plus "n" records. (e.g. if you child is seven levels deep you will create seven records one for the child and one for each parent in the chain.)
So with all that.... the issue you may be facing could have to do with the timing of the setting of the value. My opinion is that you should use your custom attribute to derive the correct location value and simply populate that into your location field. Then on save, let Maximo do what it does on location hierarchy.
------------------------------
Bradley K. Downing , MBA
Senior Brand Technical Specialist
IBM
Bakersfield CA
------------------------------
Original Message:
Sent: Tue January 10, 2023 09:30 AM
From: Abdelrhaman Elwakeel
Subject: assign new attribute in LOCATIONS to Parent in (LOCHIERARCHY) - Automation Script
Hi Bradley,
Thanks for reply me, I want to explain more about the above
I want to assign value to Parent in lochierarchy and not the opposite
My clients have a unified code in the locations, for example, they have a location hierarchy
type location: the stage is the parent, it is value "W-000" example,
and other type location: sub-location is the child, it is Value "W-000-PP"
In this, while adding a new location in type a sub-location that belongs to the stage, I used to customize to generate location code,
I have two fields, one is the use of a domain of the location, its "stage" type, and the other "sub-location" type that a user adds it.
I want the value stage (this is the parent) assign to lochierarchy after save location application, and systemid is value fixed.
Summary How to use moving a value in location to the lochierarchy with the value systemid is fixed? I've tried but it seems an unusual exception!
Do you have an idea to solve this problem?
thanks
------------------------------
Abdelrhaman Elwakeel
Original Message:
Sent: Fri April 29, 2022 02:44 PM
From: Bradley Downing
Subject: assign new attribute in LOCATIONS to Parent in (LOCHIERARCHY) - Automation Script
Howdy!
Not fully following the challenge here but if I understand this you are trying to get the LOCHIERARACHY values and set new custom attribute values on the LOCATIONS object yes? If so the code above does not actually do any get statement form the associated LOCHIERARCHY object to the intended LOCATION object. I see that you are do a set statement on the LOCATIONS object (ostensibly), but if you code is in fact getting any values form the LOCHIERARCHY object I do not see that.
I do have a question for you though: Why are you doing this? Is this for display purposes? Were you not able to do that with a non-persistent attribute and relationship in application designer? Does you customer need to see the location's parent location on the screen without using the drill down feature? If so, how is this actually driving business value of the customer? If they do not have this, will it cost them money (increase risk, etc)?
They are having you spend time and money on developing a solution that may or may not actually drive business value. Also, this is wholly dependent upon the primary geolocation system id that you have apparently hard-coded. Is that wise? I dunno.... but, if they have multiple systems then understanding which parent is what is important, and having that now built into the data for a given system may or may not be wise. Now if they do NOT have multiple systems then my view this is not a good investment. Reason: See picture below. One can view the parent of the location right in the software out of the box. This feature goes back a long way. I think all the way back to 4.1.1 (some 20 years). So again, why is the effort being made to copy the parent location value to the location record?
know enough...
------------------------------
Bradley K. Downing , MBA
Solutions Engineer
IBM
Bakersfield CA
Original Message:
Sent: Thu April 28, 2022 08:28 AM
From: Abdelrahman Elwakeel
Subject: assign new attribute in LOCATIONS to Parent in (LOCHIERARCHY) - Automation Script
Hi,
my client want filed LOCATION combination from SITEID ,ORGID ,Parent (this is new attribute "WORKSTATIONPARENT") if exist and code (also new attribute) when save it and same time I want assign attribute WORKSTATIONPARENT in LOCATIONS to attribute Parent in LOCHIERARCHY with value systemid is Fixed value. I understand LOCCATION must be unique and after save not change.
I used object launch point - Save for Object LOCHIERARCHY (Jython)
from psdi.mbo import Mbofrom psdi.mbo import MboConstantsvalue=mbo.getString("LOCATIONS.WORKSTATIONPARENT")if (value is not NONE): mbo.setvalue("SYSTEMID","GEO_HC",MboConstants.NOACCESSCHECK) mbo.setValue("PARENT",value,MboConstants.NOACCESSCHECK)
Not working Well.
Do you have an idea for a solution?
thanks
------------------------------
Abdelrahman Elwakeel
------------------------------
#Maximo
#AssetandFacilitiesManagement