Role automation acript
The role automation script feature requires Manage 8.2.0 or Maximo 7.6.1.3. Roles play an important part in Workflow and Communication Templates. Roles often resolve to a specific person or email based on data in the record, such as the supervisor on the Work Order. In those cases, this functionality is not needed.
You would use this functionality when the scenario becomes more complicated, such as if you want to check the person’s supervisor hierarchy until you get to someone with sufficient approval limits that can approve the PO. When you only need to return a single value, you could create a non-persistent attribute and populate that attribute using an Attribute launch point. However, that would require an outage for the database configuration and would not support returning more than a single value. This is where the Role Automation Script comes in.
To create a role-based Automation Script, create a role with Custom class type and the value as “com.ibm.tivoli.maximo.script.ScriptCustomRole”.
The name of the role, which is EMXROLE in this example, will be utilized in defining the automation script. The script is created without a launch point in the name format MAXROLE.ROLENAME. For example, in this case MAXROLE.EMXROLE.
IMPORTANT: Ensure that you enable the ability to invoke script functions. This is disabled by default and the script will not execute without this. You cannot change this after creation, so you will need to delete and recreate the automation script if you forgot to enable it.
There are two functions that you can declare in your script that will be invoked. You can declare evalToEmail or evalToPerson functions. Those functions will be passed as a variable that will expose the methods from the ScriptRoleContext. ScriptRoleContext extends ScriptService so all of those methods are available as well.
Public methods available in ScriptRoleContext
Method name | Parameters (Type) | Description |
---|---|---|
getMaxRole | None | Returns the MAXROLE Mbo. This class exposes a variety of methods that can be utilized such as getPerson(personid) to get a person MBO. |
addEmailId | Email (String) | Adds a new email address to the array to be sent. |
getEmailIds | None | Returns the string array of the emails that have been added. |
setPersonOrGroupMbo | Mbo (Mbo) | Sets either a Person MBO or PersonGroup MBO. |
getPersonOrGroupMbo | None | Returns the Person or PersonGroup MBO that has been set. |
getMbo | None | Comes from ScriptService but will be commonly used. This returns the MBO record (IE WORKORDER) for resolving. |
Example script
def evalToPerson(ctx):# This method comes from the ScriptServicembo=ctx.getMbo()personGroup=Noneif mbo.getString("SITEID")=="BEDFORD":personSet=mbo.getMboSet("$EMXPERSONGROUP","PERSONGROUP","persongroup='TIER1'")personGroup=personSet.moveFirst()else: