Original Message:
Sent: 07-12-2023 16:34
From: Steven Hauptman
Subject: Auto Script - Labor Record Creation
Hi Carlos,
I saw some odd behavior in both scenarios. Removing the two saves seems to resolve things and I saw a labor record created both manually and via MAS. In general, save should be avoided in a script, especially a field validation. Let me know if that adjustment works for you.
------------------------------
Steven Hauptman
IBM
Original Message:
Sent: 07-12-2023 11:14
From: Carlos Mestre
Subject: Auto Script - Labor Record Creation
Hi Steven,
This script has an attribute launch point on attribute Personid, object Person. I checked the logs, and it looks like the script was launched. See the logs message below:
[7/11/23, 19:40:53:703 GMT] 00006e30 SystemOut O 11 Jul 2023 19:40:53:703 [DEBUG] [MXServer] [CID-MXOSLC-568003] PERSONScriptMboEventListener eventAction called. for script THD_LABOR launch point THD_LABOR
------------------------------
Carlos Mestre
Home Depot
Original Message:
Sent: 07-11-2023 20:09
From: Steven Hauptman
Subject: Auto Script - Labor Record Creation
Hi Carlos, what is the launch point you are using? Are there any errors in the log or and indication the script was launched?
------------------------------
Steven Hauptman
IBM
Original Message:
Sent: 07-11-2023 11:06
From: Carlos Mestre
Subject: Auto Script - Labor Record Creation
Hi All,
I have been working on a script that auto creates a labor record when a new user is created. Here is the manual process I follow today:
- I manually create a new a User in MAS (This process will stay the same).
- New User record is automatically created in Manage.
- New Person record is automatically created in Manage.
- I manually create the user's labor record in Manage.
The auto script below successfully creates a new labor record when I manually create a Person record. However, when a new user is created through MAS and the person record is automatically created, the script does not run. Could someone please assist?
from psdi.mbo import MboConstants
# Get the personid value from the person object
# Check if the personid record is newly created (isNew() method checks if the record is new)
if mbo.isNew():
personid = mbo.getString("PERSONID")
# Check if the personid is not empty
if mbo:
# Get the Labor object and create a new labor record
# Get the LaborCraftRate object and create a new laborcraftrate record
laborSet = mbo.getMboSet("$LABOR", "LABOR", "1=0") # Create an empty labor set
labor = laborSet.addAtEnd()
laborCraftRateSet = labor.getMboSet("$LABORCRAFTRATE", "LABORCRAFTRATE", "1=0") # Create an empty laborcraftrate set
laborCraftRate = laborCraftRateSet.addAtEnd()
# Set the labor id to match the personid
# Set the craft code and laborcode values for the laborcraftrate record
labor.setValue("LABORCODE", personid)
laborCraftRate.setValue("CRAFT", "MAINT")
laborCraftRate.setValue("LABORCODE", personid)
laborCraftRate.setValue("DISPLAYRATE", "35")
# Save the labor record
laborSet.save()
# Save the laborcraftrate record
laborCraftRateSet.save()
#MaximoApplicationSuite
------------------------------
Carlos Mestre
Home Depot
------------------------------