I want to create automation script, every time when I choose ticket in my list in service request and if owner is null to fill owner with logged user. I can not use automation script launch with attribute because I do not use any attribute to start script. I tried to use automation script with object and if I choose event initialize the value it's working when I click on ticket without owner, but when I want to create new ticket I have error with historyflag
.
Can I use mxevent=selectrecord
somehow?
I use simple code with variable owner=user
.
Instead of using the Object->Initialize event for your launch point, you should use Object->Save->Before Save and have an Event Condition of :owner is null and :historyflag = 0
. This will cause owner to get set whenever you save and owner is not already set.
In my opinion, this is preferred over what you asked for for several reasons. First, when the user loads the record, they will be able to see that it is unassigned. Second, automated changes to the record will not be made unless the user makes other changes as well. Finally, the user will not be asked to save if they just load the record and then navigate away.
However, if you really want what you asked for, the following script with a launch point on Attribute->Initialize should work.
# When a user loads a record, Maximo makes a new MboSet with just that
# record. Without access to the UI, checking that ours is the only Mbo
# in the set is close to checking that we are NOT on the List tab.
if (not mbo.getThisMboSet().getMbo(1)
and not mbo.isFlagSet(mbo.READONLY)
and not thisvalue):
thisvalue = user