MBOs in Automation Scripts: Update Attributes of an Mbo

In our previous posts in this series, we talked about how an MboSet is a collection of Mbo objects. This is analogous to a spreadsheet of data representing an MboSet, and a single row within that spreadsheet representing an Mbo. This article will discuss how to update single attributes on an Mbo, or in our spreadsheet analogy, update data within a single cell within a row.

To modify an object in the collection, the object must first be found. Most of the time, the launch points in automation scripts will supply an implicit variable called mbo that refers to the current record. Alternatively, you can get a handle to an Mbo from an MboSet as described in previous articles of this series – remember the setWhere() and moveFirst() methods. Once you have an Mbo, changes are made using the setValue() method. As is the case with other methods, setValue() is a member of both the Mbo and MboSet classes.

Our first example changes the description of the current Mbo (a work order) by calling the mbo variable’s version of the setValue() method.

mbo.setValue("DESCRIPTION", "Changed the description")

In the setValue() method, passing the second argument as a string works for all attributes, regardless of their underlying data types. For example, if an attribute is a numeric type, passing the string “1” is allowed. There are also setValue() method calls that take the long, int, Date, boolean, float, or double data types as the second argument.

This call will throw an exception if the underlying data type does not match the type of the value passed in the call. For example the following code does not work.

mbo.setValue("description", 1.0)

A call to set the value of a particular attribute may result in the values of other attributes changing. For example, setting the “assetnum” attribute of a work order may result in the “location” attribute being updated as well. To check the new value, getString() could be used on the “location” attribute.

Once all values have been modified, the save() method can then be called.

mbo.getThisMboSet().save()

This saves and commits all changes to the database. In most cases, an explicit call to save() is not necessary. In cases where the automation script fires before the save event, the save event will trigger automatically after the execution of the script.

If there is an error during the save, an exception is thrown and the changes are not saved. In that case, the collection is left in exactly the same state as prior to the save() call. This allows appropriate action to be taken and the save() call to be resubmitted.

There is a third argument that can be passed to the setValue() method, which is the Access Modifier. This should only be used when you are certain of the implications of using it. In essence, standard application logic can be bypassed by using access modifiers, which is why they should be used only when necessary. Standard access modifiers are:

  1. NOACCESSCHECK: Suppresses the “Field is Read Only” message and performs the update regardless of whether the field is editable or not.
  2. NOVALIDATION: Update the field without validating the data being entered.
  3. NOACTION: Do not perform related system actions when updating. For example, do not update the location on a work order when updating the asset.

These access modifiers can be used on an update by themselves or combined together. For example, to update a field even though Maximo has the field marked as read only:

mbo.setValue("DESCRIPTION", "Update a read only field", mbo.NOACCESSCHECK)

To update a field and not perform the validation and action events:

mbo.setValue("DESCRIPTION", "Update a field without validation or action", mbo.NOVALIDATION|mbo.NOACTION)

Putting all three together:

mbo.setValue("DESCRIPTION", "Please be careful doing this", mbo.NOACCESSCHECK|mbo.NOVALIDATION|mbo.NOACTION)

A list of attributes whose values may be modified and the objects to which they belong can be found in the MAXATTRIBUTE table in the MAXIMO database. The OBJECTNAME column of this table corresponds to the object name. The ATTRIBUTENAME column corresponds to the attribute name.

Our next article will focus on how to add new Mbo records into an MboSet.

Related posts

5 comments

  • Pablo Condoleo

    Hi I’m writing a script automation with object launch point and it’s raises error message “indefined mbo variable” on this line mbo.SetFieldFlag(“quantity”,MboConstants.READONLY,false). I don’t understand this error because it’s supposed that mbo is an explicit variable.

    Thanks and regards

    Pablo

    • A
      Alex Walter

      If you’re using an Object launch point, then you should have mbo as an implicit variable to the script. To make a field read-only, you’ll probably want to use the initialize value event that’s part of the Object launch point.

      As for the code, since the Mbo class implements MboConstants you can write your script like this. Please note this is python syntax:
      mbo.setFieldFlag("quantity", mbo.READONLY, False)

      Hope this helps,
      Alex

  • Hi Alex.
    I wrote this script to copy the value from existing table in maximo to my new table. The tables are the same i mean same attributes. So when the status changes it should pass from old table to the new one.
    First i try to add just work order number but it doesnt copy the values and it doesnt give any error.

    #Add records in Z0PLANNEDCOST table when the new work order added to the workflow.
    #Statutes are WAPPR, ASSEGNATO, COMP, ASSEGNATOWF, AVVIATO

    #Attribute Launch Point: STATUS

    from psdi.server import MXServer
    from psdi.mbo import Mbo
    from psdi.mbo import MboConstants
    from psdi.mbo import MboRemote
    from psdi.mbo import MboSetRemote
    import sys

    from psdi.util.logging import MXLoggerFactory
    logger = MXLoggerFactory.getLogger(“maximo.script”)

    sourceItemSet= mbo.getMboSet(“SHOWPLANITEM”)
    #sourceItemSetSelection=sourceItemSet.getSelection()

    targetItemSet= mbo.getMboSet(“PLANNEDZ0WPITEM”)

    status = mbo.getString(“STATUS”)

    #i=0
    if status in (“AVVIATO”):
    for i in range (0, sourceItemSet.count()):
    if targetItemSet is not None:
    newMbo=targetItemSet.add()
    wonum =sourceItemSet.getMbo(i).getString(“WONUM”)
    logger.info(“COMPY VALUES” + ” – ” + wonum )
    newMbo.setValue(“WONUM”,wonum,MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION)

  • Raymond Lian

    This was very informative and awesome. Thank you, Alex.

    Does capitalization matter with the keys for Mbo? Would mbo.setValue(“ACCESS_KEY”, “5^*^%$TRUE”); change the same cell as mbo.setValue(“AccessKey, “5^*^%$TRUE”);

    Why does this happen?
    A call to set the value of a particular attribute may result in the values of other attributes changing. For example, setting the “assetnum” attribute of a work order may result in the “location” attribute being updated as well. To check the new value, getString() could be used on the “location” attribute.

    In most cases, an explicit call to save() is not necessary.
    What makes it a case where it is necessary?

    • Alex Walter

      No problem, thanks for the questions!

      1. Capitalization does not matter. Maximo will locate the correct attribute to update regardless of the case you use to identify it.
      2. Business rules in Maximo may apply to certain fields. The location of a work order is updated automatically when an asset is updated because the asset resides in a certain location. If the location is empty and an asset is chosen, you would want the location to default to that of the asset you selected. This is a simple case, but it extends throughout the Maximo application.
      3. The call to save() is not necessary if you update an MboSet that is related to the current Mbo. This is because the save() will automatically fire on the current record, and any related MboSet’s will also be saved. If you get an independent MboSet from the MXServer (see examples from the first article in this series) you will need to explicitly save.

      Hope this helps!

Shane

Maximo Analyst

As a recent graduate in computer science and cybersecurity with a CompTIA Sec+ certification, I thrive on learning and embracing emergent challenges head-on. Though new to Maximo, I approach the day to day with determination and enthusiasm. I have been known to be competitive while also being a strong team player. Beyond the realm of technology, I cherish spending time with loved ones, playing video games, doing exercise, and cooking. I am grateful to be where I am and around so many amazing people.

MAS 8

Time to Benefit
Lower Costs
Scalability and Integration
Continuous Upgrades
Easy of Use

Visual Inspection

Accelerate Defect Detection
Flexibility to Train and Deploy
Increase Uptime 24/7 Real Time Monitoring
Better Worker Safety

Monitor

Enterprise Level Data Aggregation
Scaled Operations
AI Deductions
Advanced Root Cause Analysis

Predict

Condition Based Maintenance
Lower Costs
Better Asset Availability
Reduced Risk

Manage

Comprehensive View of Assets
Understand Resource Attributes, Configuration and Relationships
Drill Down View

Health

Improve Reliability
Performance Insight
Better Planning
Clean Data
Optimization – Data, Costs, Risks

Mobility

Boost Productivity
Safer Workplace
Reduce Knowledge Gaps
Avoid Downtime

Digital Twin

Integrate with IoT for Intelligent Asset Management
Measure Health and Performance
Meet Sustainability Goals
Write Your Digital Story – Learn from Data

Dexter

Maximo Analyst

Dexter began his career in the warehouse field. Developing his skills in inventory control, accounts payable, shipping, and receiving, and procurement. While working at Apex he was learning the Maximo system in and out. Eventually learning it so well he taught everyone how to use it. Eventually becoming a system administrator for the Apex site.

A fun fact about Dexter is that he was an Elvis impersonator for 24 years. He enjoys singing, fishing, golf, and playing pool. He's an avid movie buff, most likely you'll find him watching the latest movie.

Chip

Client Relations Specialist

Chip is new to Maximo but has worked for various software companies through his career in both a sales and client relations role. In his spare time, Chip likes to golf, travel and work on projects around the house, especially those with an artistic touch. He is also up for any type of competition whether that be playing cards, board games or recreational sports.

Sarah

Maximo Analyst

Sarah is a recent graduate starting her asset management career. She counts fast learning and determination as key skills that she’s applying to become an Maximo pro! Sarah’s background in IT Services and studies in computer science have strengthened her natural problem-solving skills and desire to help others through technology. In her free time, Sarah enjoys baking, sewing, reading comic books, and building her own video game.

Derrick

Maximo Analyst

Derrick is someone who lives for mental exercise. New challenges spin his problem solving wheels. Defeat is not an option and challenges make him smile. His catch phrase is “I’m an Engineer”. Derrick takes pride in his work. He is a highly self-driven talent when it comes to his interests and programming couldn’t be any higher on this list.

Outside of the office Derricks interests includes cars, motorcycles, and anything generally fast and loud. He stays in the loop on latest in tech, loves gaming and most of all is a die-hard anime fan. Outside of bike night, you are most likely to catch him relaxing in the glow of lights from his PC.

Xavier Galarza

Maximo Analyst

I am a recent graduate who is motivated to learn and develop new skills. I like to challenge myself every day. I want to learn all about Maximo in order to teach others how effective Maximo can be for them. I have a good understanding of the development side and work well with problem solving. I am grateful for the position I am in, I love surrounding myself with great people that are more knowledgeable than me who will help me grow as a person. In my free time I love to play videos games, watch/ play sports and spend time with family. I am a competitive person and believe I am pretty good at all sports.

My other passion is to stream video games I play and connect with others online, I love showing others how to play a certain game or even show them a skill didn’t know existed. I love entertaining others and creating content for others to watch and enjoy.

Courtney LeBlanc

Business Analyst

Courtney is a polished Maximo consultant with over 10 years working in the industry. She has worn many hats including QA Specialist, Trainer, Functional Lead, Project Lead and Business Analyst. A point of great professional pride for Courtney is helping clients meet their needs and realize the power of their investment. Being a part of the process that helps clients learn how to use their system and get the most out of it is a great feeling at the end of the day.

Bob Richardson

Director of Managed Services and Senior Analyst

Bob has led more than 50 (but less than ∞) Maximo projects with top notch client satisfaction – so he must be doing something right. He is a seasoned veteran who heads our operational & managed services team. He is instrumental in developing many of our solutions and holds Maximo certifications in both functional and technical disciplines up to version 7.

Bob might or might not like squirrels. He enjoys traveling with his wife and outdoor activities. He has also been known to spend long hours in his garage contemplating life.

Kelly Nimmo

Director of Products and Senior Analyst

Kelly heads up our product development team and is a senior analyst with more than 11 years EAM/Maximo experience. She is the architect behind our flagship product offering MxMobile. She holds Maximo certifications in both functional and technical disciplines up to Maximo version 7.

In her free time if you don't find her on her boat, fishing and enjoying the beautiful Florida outdoors, then she's probably on the soccer field teaching her nieces and nephews how to do the around the world.

Kim Walter

COO

Kim began her career in Investment Banking in the Biotech and Tech sectors. After leaving banking, she focused on executive strategic development evolving her business building skills. Co-founding A3J Group was a natural fit with the idea of creating a fierce ninja style unit that outperforms all others. In her free time, she is training for her next eventing competition or studying to become a Master of Wine or practicing her tornado kick. She could be with her family hiking or surfing or cooking. But she’s definitely not sitting around doing nothing.

Alex Walter

CIO

Alex brings 18 years of Maximo/EAM consulting experience in Life Sciences, Oil & Gas, Water/Waste Management, Government facilities, and much more. He has been awarded the honor of IBM Champion from 2018-2021, and is the brainchild behind our revolutionary mobile solution MxMobile.

In his free time he buys camping gear, enjoys a good circular saw and spends time with his family hiking, surfing and being outdoors.

Enhancement

• Configuration
• Integration & data loading
• Report improvement
• Screen view & workflow changes

Sustainability

• Report
• Troubleshoot
• Learn
• Teach
• Lead

Change Management

• Advanced systematic improvements
• Tailored procedure implementation
• Script-, report-, and application-level source and document control through Git repository software
• Training on how to document and deploy changes

Monitoring

• Active monitoring of your IBM Maximo system’s heartbeat
• Triggered notifications and support tickets when Maximo is not responding
• Automated Escalations based on the health of various critical background processes.
• Periodic and quarterly scheduled system health checks

System Support & Trouble Shooting

•On Demand Support
•Advanced Troubleshooting
•Access to A3J Group’s Maximo Support Environment to submit trouble tickets
•Directly report bugs, request fixes and enhancements

System Patching & Environment Refreshes

• Tentative, bi-annual feature pack releases from IBM
• Minor patches (defined by the last number in the version model)
,• Quarterly lower environment refreshes

Admin

MxAsk

Create new self-service requests in a wizard-style format, and view the details of their open service requests.

MxApprove

Accept, reject, and reassign assignments, review assigned records, and view your workflow inbox.

MxMobile

A suite of mobile applications designed to integrate with IBM Maximo Asset Management. These apps modernize workflow, expedite inventory processes, reduce time spent on data entry, and more.

Workflow

MxMeter

View and enter meter readings, view trends in graphical format, and create readings while in offline mode.

MxAsset

Scan barcodes and view maintenance facts. Create meter readings, work orders or service requests. Toggle asset downtime.

MxWork

Create new work orders on the go, view existing work orders and attachments, and capture fingertip electronic signatures.
0