Maximo

Maximo

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

 View Only
Expand all | Collapse all

Use attribute formula to conditionally open an error message

  • 1.  Use attribute formula to conditionally open an error message

    Posted Fri October 29, 2021 05:31 PM
    Edited by System Admin Wed March 22, 2023 11:54 AM
    MAM 7.6.1.2:

    Is there a way to use an attribute formula to conditionally open an error message?


    Example:
    In WOTRACK-->Actuals-->Labor, if the Premium Pay Code is not null, and the Premium Pay Hours is null or zero, then open an error message (prevent the WO from being saved).
    #Maximo
    #AssetandFacilitiesManagement


  • 2.  RE: Use attribute formula to conditionally open an error message

    Posted Fri October 29, 2021 05:31 PM
    Edited by System Admin Wed March 22, 2023 11:55 AM
    It looks like the answer is yes.

    Since formulas use the same functions as MBR scripting, I went through the MBR documentation and found a MBR function called ERROR():
    • "error(errgrp, errkey)
      Throw MXException with the error group errgrp and error key errkey. This is useful in validation scenarios when we would like to throw an error. Note that the errgrp and errkey needs to get registered in Maximo messages.
      It’s a single line code with an if control structure."
    Formula:
    • IF(isnotnull$PREMIUMPAYCODE && (PREMIUMPAYHOURS=0 || isnull$PREMIUMPAYHOURS), error("MyGroup","premium_hrs") )
    • Syntax: "&&" is how we write "AND"  ...   " || " is how we write "OR" 
    • The IF statement doesn't have an ELSE argument. In other words, it never updates a field with a value. More information here: 
      How to "do nothing" in attribute formula IF statement (if X, then Y, else DO NOTHING).
    • That's how I get away with assigning this attribute formula to the ORGID field. The formula never returns a value, so ORGID never gets updated. I used an existing field because it avoids the need to create a new field (requiring a db config outage).
    • I didn't have a specific reason for choosing the ORGID field, other than the fact that it's used in most tables (makes the formula feel generic), and anyone who saw the ORGID field in a formula would know that we're not actually populating ORGID, since there would never be a case when we'd do that. And even if I made a mistake and accidently tried to populate ORGID with an attribute formula, it doesn't work. If I try to populate ORGID with "test" or NULLVALUE(), nothing happens. ORGID doesn't get updated.
    Result:
    When I attempt to save the WO with a labor actual that has incorrect premium pay information, Maximo throws an error, which is what I want. The WO can't be saved.






    Summary:

    This was just an experiment.
    In reality, I probably wouldn't use an attribute formula for this purpose. It would be just as easy to do this with an automation script. And it's handy to put all custom login in a single place: the Automation Scripts application.

    The only possible upside I can think of to using a formula for this would be: there's a chance that IBM would support it, since it uses OOB functionality. But it's not like using an automation script for this would involve complex logic that would be difficult to maintain anyway, so that might be a moot point.

    It's still neat to know that it works though.
    #Maximo
    #AssetandFacilitiesManagement