title: Maximo Assetspec automation script slowness and error
body: <p>Below is my automation script that is the second part of an asset loading process. The first part loads attribute data to the asset upon creation from an external system but it also sets the CLASSIFICATIONID which creates records in the ASSETSPEC table which fires the below script:</p>
  
  <pre><code>from psdi.mbo import MboConstants
  from psdi.server import MXServer
  from psdi.security import UserInfo
  
  username = "maxadmin"
  
  mxServer = MXServer.getMXServer()
  userInfo = mxServer.getUserInfo(username)
  
  if mbo != None:
      mxAssetSpec = mbo
  
      AssetNum = mxAssetSpec.getString("assetnum")
      SiteID = mxAssetSpec.getString("siteid")
  
      gisAssetSet = mxServer.getMboSet(FEATURECLASS, userInfo)
      gisAssetSet.setWhere("mxassetnum = '" + AssetNum + "' and mxsiteid = '" + SiteID + "'")
      gisAssetSet.reset()
  
      gis = gisAssetSet.getMbo(0)
  
      if FEATURECLASS == "GRAVITYSEWERLINES":
          if ASSETATTRID == 'MATERIAL':
              mxAssetSpec.setValue("alnvalue", gis.getString("material"))
              mxAssetSpec.setValue("startmeasure", '0')
              mxAssetSpec.setValue("endmeasure", gis.getString("length_"))
              mxAssetSpec.setValue("startmeasureunitid", 'FT')
              mxAssetSpec.setValue("endmeasureunitid", 'FT')
          if ASSETATTRID == 'LENGTH':
              mxAssetSpec.setValue("numvalue", gis.getString("length_"))
              mxAssetSpec.setValue("startmeasure", '0')
              mxAssetSpec.setValue("endmeasure", gis.getString("length_"))
              mxAssetSpec.setValue("startmeasureunitid", 'FT')
              mxAssetSpec.setValue("endmeasureunitid", 'FT')
          if ASSETATTRID == 'INSTALL':
              mxAssetSpec.setValue("alnvalue", gis.getString("instalyear"))
              mxAssetSpec.setValue("startmeasure", '0')
              mxAssetSpec.setValue("endmeasure", gis.getString("length_"))
              mxAssetSpec.setValue("startmeasureunitid", 'FT')
              mxAssetSpec.setValue("endmeasureunitid", 'FT')
          if ASSETATTRID == 'ESTYEAR':
              mxAssetSpec.setValue("alnvalue", gis.getString("est_year"))
              mxAssetSpec.setValue("startmeasure", '0')
              mxAssetSpec.setValue("endmeasure", gis.getString("length_"))
              mxAssetSpec.setValue("startmeasureunitid", 'FT')
              mxAssetSpec.setValue("endmeasureunitid", 'FT')
          if ASSETATTRID == 'PDIAM':
              mxAssetSpec.setValue("numvalue", gis.getString("diameter"))
              mxAssetSpec.setValue("startmeasure", '0')
              mxAssetSpec.setValue("endmeasure", gis.getString("length_"))
              mxAssetSpec.setValue("startmeasureunitid", 'FT')
              mxAssetSpec.setValue("endmeasureunitid", 'FT')
  
      mxAssetSpec.save()
      mxAssetSpec.close()
      mxAssetSpec.resetForRefreshOnSave()
  
  else:
      raise UnboundLocalError
  </code></pre>
  
  <p>There are about 8 classification attributes that it cycles through. The script itself runs very fast but there is a pause of about 3 seconds between each classification attribute. And i also get an oracle error:</p>
  
  <p>java.sql.SQLException: ORA-00904: "ASSETNUM": invalid identifier</p>
  
  <p>The only place i am referrencing ASSETNUM is when i am retrieving the string from the ASSETSPEC MBO which assetnum is an attribute of so i am confused why i am getting this error.</p>
  
  <p>My questions are, why am i getting the invalid identifier error and why is there a pause, and are they connected?</p>
  
  <p>The script takes about 20 seconds to complete and works fine but 20 seconds is about 19 seconds too long. Any help would be appreciated. Also any comments on how to improve the code would be appreciated.</p>
  
  <p>Thanks!</p>
  
  <pre><code>if mbo != None:
  mxAssetSpec = mbo
  
  mxAssetSet = mxAssetSpec.getMboSet("ASSET")
  mxAsset = mxAssetSet.getMbo(0)
  featureclass = mxAsset.getString("PLUSSFEATURECLASS")
  assetattrid = mxAssetSpec.getString("ASSETATTRID")
  
  print(featureclass)
  print(assetattrid)
  
  if featureclass == "GRAVITYSEWERLINES":
      gisAssetSet = mxAssetSpec.getMboSet("SPATIAL_GRAVITYSEWERLINES")
      gis = gisAssetSet.getMbo(0)
      length = gis.getString("length_")
      if assetattrid == 'MATERIAL':
          mxAssetSpec.setValue("alnvalue", gis.getString("material"))
          mxAssetSpec.setValue("startmeasure", '0')
          mxAssetSpec.setValue("endmeasure", length)
          mxAssetSpec.setValue("startmeasureunitid", 'FT')
          mxAssetSpec.setValue("endmeasureunitid", 'FT')
      if assetattrid == 'LENGTH':
          mxAssetSpec.setValue("numvalue", gis.getString("length_"))
          mxAssetSpec.setValue("startmeasure", '0')
          mxAssetSpec.setValue("endmeasure", length)
          mxAssetSpec.setValue("startmeasureunitid", 'FT')
          mxAssetSpec.setValue("endmeasureunitid", 'FT')
      if assetattrid == 'INSTALL':
          mxAssetSpec.setValue("alnvalue", gis.getString("instalyear"))
          mxAssetSpec.setValue("startmeasure", '0')
          mxAssetSpec.setValue("endmeasure", length)
          mxAssetSpec.setValue("startmeasureunitid", 'FT')
          mxAssetSpec.setValue("endmeasureunitid", 'FT')
      if assetattrid == 'ESTYEAR':
          mxAssetSpec.setValue("alnvalue", gis.getString("est_year"))
          mxAssetSpec.setValue("startmeasure", '0')
          mxAssetSpec.setValue("endmeasure", length)
          mxAssetSpec.setValue("startmeasureunitid", 'FT')
          mxAssetSpec.setValue("endmeasureunitid", 'FT')
      if assetattrid == 'PDIAM':
          mxAssetSpec.setValue("numvalue", gis.getString("diameter"))
          mxAssetSpec.setValue("startmeasure", '0')
          mxAssetSpec.setValue("endmeasure", length)
          mxAssetSpec.setValue("startmeasureunitid", 'FT')
          mxAssetSpec.setValue("endmeasureunitid", 'FT')
  
      mxAssetSpec.save()
  </code></pre>
  
  <p>else:
      raise UnboundLocalError</p>