Maximo Open Forum

 View Only
  • 1.  Is there a way to concatenate two attributes through Automation scripting

    Posted 04-26-2021 10:45

    Is there a way to concatenate two attributes through Automation scripting ?

    I am trying with below approach ->

    Script with attribute launch point.
    OBJECT -->INVVENDOR

    Attribute --> MODELNUM (idea is when modelnum gets changed this will combine model and catelog andsave in description field)

    from psdi.mbo import MboConstants


    modelNum = mbo.getString("MODELNUM")

    catelogNum = mbo.getString("CATALOGCODE")

    DESCRIPTION = modelNum + catelogNum

    mbo.setValue("DESCRIPTION" ,DESCRIPTION, MboConstants.NOACCESSCHECK)

    Please let me know if i am doint this incorrectly


    #Customizations

    ------------------------------
    Pradeep Rout
    TCSL
    ------------------------------


  • 2.  RE: Is there a way to concatenate two attributes through Automation scripting

    Posted 04-27-2021 08:44
    Hi Pradeep,

    I created a simple python script to concatenate a job plan description on to a work order description (pm record description) at PM wogen.  It is an object launch point auto script on the work order object.  It could easily be an attribute launch point.

    The two variable and binding respectively:
    • jpdesc
      • Variable Type:  IN
      • Binding Type:  Attribute
      • Binding Value:  JOBPLAN.DESCRIPTION
    • wodesc
      • Variable Type:  INOUT
      • Binding Type:  Attribute
      • Binding Value:  DESCRIPTION

    Script:  wodesc = str(wodesc) + '--' + str(jpdesc)


      ------------------------------
      Bill Steudler
      The Pennsylvania State University
      ------------------------------



    • 3.  RE: Is there a way to concatenate two attributes through Automation scripting

      Posted 04-27-2021 09:42
      Since you're dependent on 2 attributes (MODELNUM & CATALOGCODE), you'd either want two attribute launch points (one on each attribute, ideally action so that it's after the validation succeeds on the field) or an object launch point (such as Save) like Bill utilized. 

      You can avoid the MboConstants import by utilizing "mbo.setValue("DESCRIPTION" ,DESCRIPTION, mbo.NOACCESSCHECK)". Simplifies the code a bit and makes it run ever slightly faster.

      The one thing I'd caution is you always run the risk of the two attributes being larger than the value allows. Out of box this exact scenario isn't an issue (since the two are significantly less than 100) but if you are concerned that you might at one point exceed the length it's good to write checks to avoid unhandled exceptions. For example, you could get the first 100 characters by doing something like DESCRIPTION[:100] which would avoid getting a size issue if it exceeds 100 characters (though it'd be better to get the actual size then have a hardcoded limit like this). To get the actual size of description, you can call mbo.getMboValue("DESCRIPTION").getLength()


      ------------------------------
      Steven Shull
      Projetech Inc.
      ------------------------------