I have a custom application with our space information room directory, that has a relationship to Locations. I'm trying to place a button in that application to create a new Location for a specific room as needed.
I got the automation script to launch from the button in the application. It runs without any errors, but does not actually create the Location.
Below is the code I'm running, not sure what's happening.
print "STARTED CREATE LOCATOIN TEST"
from psdi.server import MXServer
#from psdi.mbo import MboConstants
from psdi.security import UserInfo
#from psdi.iface.app.location import MaxOperLocProcess
rmrecnbr = mbo.getString("RMRECNBR")
#site = mbo.getString("SITEID")
userinfo = MXServer.getMXServer().getSystemUserInfo()
if rmrecnbr is not None:
locations = mbo.getMboSet("LOCATIONS")
count = locations.count()
if count != 0:
loc = mbo.getString("LOCATIONS.LOCATION")
errorgroup = "SPC"
errorkey = "LOCEXISTS"
params = [loc]
else:
newLocationSet = MXServer.getMXServer().getMboSet("LOCATIONS", userinfo)
newLocationSet.setWhere("RMRECNBR='"+rmrecnbr+"'")
newLocationSet.reset();
newLocation = newLocationSet.add()
newLocation.setValue("LOCATION", "TESTRMNBR")
newLocation.setValue("RMRECNBR", rmrecnbr)
#newLocation.setValue("SITEID", "UMHS")
newLocation.save()
newLocationSet.clear()
newLocationSet.close()
print "New Location: " + str(newLocation)
errorgroup = "SPC"
errorkey = "LOCEXISTS"
params = [newLocation]
print( "END CREATE LOCATOIN TEST-->" + rmrecnbr +"count" + str(count))
#Support#SupportMigration#Maximo#AssetandFacilitiesManagement