After Save/After Commit require explicit saves again because the data has already been inserted/updated in the database. I don't like After Save/After Commit for most use cases, especially if you're modifying the same record. You have to ensure you prevent a loop if you save the same record. The database has to work harder as you made an insert/update already and now are making a separate update to set one field. It's like writing:
UPDATE workorder set description='Test' WHERE wonum='1000' and siteid='BEDFORD';
UPDATE workorder set assetnum='1234' WHERE wonum='1000' and siteid='BEDFORD';
instead of:
UPDATE workorder set description='Test', assetnum='1234' WHERE wonum='1000' and siteid='BEDFORD';
In the case of After Save, you have an open transaction running that has manipulated the database which can cause blocking in the database while that script is running. So if you have a slow operation (reaching out to an external system for example) I'd be hesitant to go that approach.
------------------------------
Steven Shull
IBM
------------------------------
Original Message:
Sent: 12-01-2021 23:04
From: User 1972
Subject: Autoscript: Populate field with value from SQL query
Hi Alex,
In a reply above, I mentioned:
"I couldn't figure out how to set up the launch point on the script so that it fired after commit. I'm not sure if the "After Commit" option in object launch points is known to be finicky. Or if it's just me. But I didn't get it working."
I have a vague memory from reading one of your posts that it's sometimes necessary to do an "explicit save" when setting a value -- depending on the launch point type.
Is there any chance that rings a bell? I can't remember where I saw that.
Thanks.
------------------------------
User 1972
Original Message:
Sent: 11-22-2021 09:08
From: Alex Walter
Subject: Autoscript: Populate field with value from SQL query
The best way to create views in Maximo - my opinion - is using DBC scripts. These give you flexibility that you don't have in the Database Configuration application. I'll have to write an article on that one of these days.
------------------------------
Alex Walter
A3J Group, LLC
Original Message:
Sent: 11-10-2021 08:47
From: User 1972
Subject: Autoscript: Populate field with value from SQL query
Edit:
I've moved this conversation about "trouble with views" and "attribute Search Type is read-only" to a separate post:
IMPORTED DB VIEW: HOW TO SET CALCULATED/PERSISTENT TEXT ATTRIBUTE SEARCH TYPE TO WILDCARD?
Thanks Craig.
Here's the reason reason I find views to be a pain:
When I import a view to Maximo using the steps you described, the Search Type of the attributes gets automatically set to NONE by default. And the Search Type is read-only, so I can't set it to what I want (like WILDCARD). It's my understanding that text fields need to have a Search Type of WILDCARD in order for me to filter on the field in the Advanced Search window and in the list view. If the Search Type is NONE, then I don't think I can filter on the field in Maximo.
I also don't have CREATE VIEW privileges in the database. So creating imported views (directly in the DB) is a challenge.
------------------------------
User 1972
Original Message:
Sent: 11-10-2021 00:36
From: Craig Kokay
Subject: Autoscript: Populate field with value from SQL query
Hi User 1972,
Yes, you should be able to, not sure of the code. But I have learned something new and that is exciting. That is the listagg function. Simple and effective.
Doing views, in general, is very simple, so I'd be curious why you think it's hard. Like Jeff has said, create the view using SQL in the correct schema, then in DB config, simply name the new object the same. Maximo will then import your work, config, and you're up and running.
I'd recommend in the view to include the CLASSSTRUCTUREID because you can then create a relationship to it from the CLASSSTRUCTURE object and use it on the list screen as per your use case.
------------------------------
Craig Kokay
ISW
Maximo Practice Manager
eMail: ckokay@isw.net.au
Phone: +61-411-682-040
#IBMChampion2021
Original Message:
Sent: 11-07-2021 16:28
From: User 1972
Subject: Autoscript: Populate field with value from SQL query
MAM 7.6.1.2; Oracle 19c:
I plan to use an automation script to update a CLASSSTRUCTURE.USEWITH field -- on save.
- USEWITH is a custom field that contains a comma-delimited list of USEWITH values for the classification. This field will be used in the Classifications application list view.
As an experiment, I want to use a SQL query to get the value that will be used to populate the field.
select listagg(objectname,', ') within group(order by objectname) as usewithfrom maximo.classusewithwhere classstructureid = '68070'group by classstructureid
Source
Question:
Is there a way to use the value from an SQL query to populate a field (via an automation script)?
(I want to avoid creating a view. I find views to be a pain to set up in Maximo.)
#Administration