Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only
  • 1.  Create Location in Automation Script

    Posted Thu December 03, 2020 01:39 PM

    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


  • 2.  RE: Create Location in Automation Script
    Best Answer

    Posted Thu December 03, 2020 06:59 PM

    My mistake was saving the Mbo when I should save the MboSet.

    I changed newLocation.save() to newLocationSet.save() and it worked. After I also added newLocation.setValue("TYPE","OPERATING")






    #AssetandFacilitiesManagement
    #SupportMigration
    #Support
    #Maximo