Showing posts with label Workflow. Show all posts
Showing posts with label Workflow. Show all posts

Friday, February 13, 2015

Use an automationscript in a Condition node of a Workflow

Goal:
Use an automationscript in Maximo to calculate the outcome of a condition node in Maximo. 

Example:
I have a record with zero or more child records. e.g. a  Workorder with Task workorders. I also have a workflow and I want the Workorder only to be able to go in to the workflow if the Tasks all have the same Location.

Problem:
Whith the condition nodes in Workflow you can set an Expression. But how can I loop through task workorders within an expression? That would make a difficult expression. Looping through records (and doing a lot of other stuff) is much easier in an automation script. How can I use the best of both worlds?

Solution:
So I need to call an automationscript from a workflow. First I set up my basic workflow. For more information about that, see one of my previous posts, with information on setting up a basic workflow.
http://sometimesiliketopretend.blogspot.com/2014/10/maximo-75-my-first-workflow.html

My workflow:




When starting the workflow, the check is performed, and when not satisfactory a message is shown to the user and the workflow is stopped.

The condtion now needs to call my automation script.

Create the script on a Custom Condition Launchpoint:



I want the script to run on the workorder object:



Name the script:



Paste in the source code for the script and click the [Create] button







Source code script:

print "Start CHECKTASKLOC script";

from psdi.mbo import Mbo;
from psdi.server import MXServer;

'''
Date: 20150211
Author: G.N. Zomerdijk

Purpose of script:
Check if the location on all tasks are the same

The script will be run from a condition node in the Workflow

Custom Condition Launchpoint: WOFLOW on WORKORDER object

Useage in Workflow:
Condition Node with title: CHECKTASKLOC:WOFLOW   That is the <script name>:<launchpoint name>
Expression:   com.ibm.tivoli.maximo.script.ScriptCustomCondition
Custom Class: Y

For reference when we want to use it in a Condition:
Create the following condition:
Condition: TEST
Type: CLASS
Expression: CHECKTASKLOC:WOFLOW 
Condition class: com.ibm.tivoli.maximo.script.ScriptCustomCondition

Info:
Expression should hold launch point information: <script name>:<launchpoint name>

evalresult is returned, is an internal variable, no need to define it as variable in automationscript application.
'''

#set values for used variables
evalresult = True;
loc = "";

#Loop through the PRLINES
tasksFromWOSet = mbo.getMboSet("WOACTIVITY")
tasksFromWO = tasksFromWOSet.moveFirst()

while tasksFromWO is not None:    
    if (loc != "" and loc != tasksFromWO.getString("LOCATION")):
        evalresult = False;
        break;
    else:
        loc = tasksFromWO.getString("LOCATION");

    #get the next task
    tasksFromWO = tasksFromWOSet.moveNext();

print "evalresult: " + str(evalresult);

print "End CHECKTASKLOC  script";


The script returns a True or a False. This is done by setting the evalresult variable. See the code above for more detailed information.

Now in the workflow we can run the script by modifying the Condition Node.

Condition Node with title: CHECKTASKLOC:WOFLOW   That is the <script name>:<launchpoint name>
Expression: com.ibm.tivoli.maximo.script.ScriptCustomCondition

Custom Class: Y




After clicking OK I get:



Click OK in the error and Click OK again in the condition node. Do not know why the error occurs, but the second time around it is validated. Maybe because the Custom Class is checked, and only at the second run the Expression is validated as a Custom Class.

The workflow looks like this now:


Save the Workflow.

Next I associate the Workflow with the Workorder (WOTRACK) application




I only add support for the WOTRACK application, so deselect the rest of the application and click [OK]



Next Validate, Enable and Activate the process:








Create a workorder, with 3 task workorders.




On one of the tasks change the location from FOORBAR to FOOBAR2 and save the workorder.



Now I want to route the workorder in the workflow, but the button is grayed out... 



I go back to the workflow and go in the Select Action menu to the "Edit Workflow GO Buttons" 

There I add the Process Name to the existing Application row.



I save the workflow and open my workorder again.
Still grayed out... I decide to now logout maximo and log back-in.
Open the workorder again and the button is now available!



And now I get the message:


I change location on the second task to match the other tasks, save the workorder and hit the workflow button again.


Now the record is routed in the workflow: 


GNZ


Reference:
For more info about automationscripting I used the pdf from this page: https://www.ibm.com/developerworks/community/blogs/a9ba1efe-b731-4317-9724-a181d6155e3a/entry/scripting_with_maximo6?lang=en

For more information about workflow I used this "Workflow Implementation Guide": http://publib.boulder.ibm.com/infocenter/tivihelp/v49r1/topic/com.ibm.mbs.doc/pdfs/pdf_mbs_workflow.pdf

Monday, October 6, 2014

Maximo 7.5 my First Workflow

Goal:
Use Workflow in Maximo to assign the flow of a request to different roles (groups of persons) 

Example:
I have a record in a cloned application that has to go through some different statuses. For example, it has to be "Approved", set to "In Progress", then "Closed".

I want to assign these changes to person(groups) so they get a message in the inbox on their startcenter. 

For more information about workflow I used this "Workflow Implementation Guide": http://publib.boulder.ibm.com/infocenter/tivihelp/v49r1/topic/com.ibm.mbs.doc/pdfs/pdf_mbs_workflow.pdf

and this link is also usefull:

https://www.ibm.com/developerworks/community/blogs/a9ba1efe-b731-4317-9724-a181d6155e3a/entry/creating_workflow_process2?lang=en



Solution:

Step 1 - Create a simple overview

In this example I just want to put a new record in the workflow, let someone determine if the record should be approved or cancelled.




Step 2 - Create Actions
In this example the record either gets approved or cancelled. I need actions to perform those status changes in out application.

First go to the Action application and add the actions. Go-To -> System Configuration -> Platform Configuration -> Actions 

I create two actions: 




Note 1: 
I use a cloned application, it is a clone of the SR application, that is why i use the SR object.

Note 2:
The APPR and CAN statuses are not default in the SR object. I added those to the SRSTATUS domain. 


Step 3 - Create Roles and Persongroups

When creating Tasks in a workflow, these task will need to be assigned to a role. These roles will be Person Groups in this example. So we first need to create "Person Groups" and then add those Person Groups to the Roles.

Add the Persongroup:



Do not forget to add at least one actual person to the Person Group, otherwise the following error will occuur when testing the workflow:

BMXAA4473E - No assignments created for task <TASKNAME> in workflow process <WFPROCESSNAME>

Add the Role:




Step 4 - Create the workflow

From the Implementation Guide I got this table with the different nodes available in a workflow.


Type of Node
Description
Lines permitted
entering a node
Lines permitted or
required exiting a
node
Start node

Indicates the point when a record starts a workflow process. When you create a process, a single start node displays on the canvas. Each process can have only one start node. You cannot delete start nodes.
None.
One positive line is required
Condition node




Indicates an evaluation of the record, based on data in the record. Use a condition node to enable a true evaluation or a false evaluation of the record, and then direct the record based on that evaluation. When a condition node is generated, it evaluates the record based on the Structured Query Language (SQL) statement defined in the properties for the node. The record is then routed to either the positive connection line or to the negative connection line exiting the node. You can use the SQL Expression Builder tool, accessed from the Workflow Configuration > Escalations application, to create an SQL statement.
One or more positive
lines; one or more
negative lines.
One positive line and
one negative line are required.
Interaction node

Provides an option for a user interaction with a record. Use interaction nodes to guide a user through a structured interaction with a record. A process can have one or more interaction nodes. You do not have to include interaction nodes in a process. A manual input node precedes an interaction node. If an interaction node leads to an application not related to the object on the process record, place a stop node after the interaction node. The original process shuts down as the new record displays.
One or more positive
lines; one or more
negative lines.
One positive line is
permitted.
Manual input node

Indicates a need for user input because there are multiple directions that a record can take in a process. Use a manual input node to have the assignee decide what happens next. When a manual input node is generated, a window displays. The manual input window contains a menu of options for routing the record. When the assignee selects an option, any actions or notifications associated with the option are triggered.
One or more positive
lines; one or more
negative lines.
More than one
positive line is
required. Negative
connections exiting
the node are not
allowed.
Subprocess node

Indicates that a separate workflow process is contained within another workflow process. Use a subprocess node to break down a complicated business process into smaller, self-contained units. For example, you could have a subprocess that handles records in different sites, or that handles different classes of work orders. When the record encounters a stop node within a subprocess, the stop node is returned to the main process. The stop node is returned at the same point where it left the process and on the same type of routing line on which it finished.
One or more positive
lines; one or more
negative lines.
One positive line and
one negative line are required.
Task node

Indicates when a user is to be given an Inbox assignment. The user has two choices. For example, the user can either approve a record or reject a record. Use task nodes when your business process requires that a user evaluate a record. Create a task assignment that routes the record to one or more individuals. Workflow comes to a stop at a task node until the assigned user has routed the record.
One or more positive
lines; one or more
negative lines.
One positive line is
required; one
negative line is
allowed.
Wait node

Indicates that the progress of a record through a process pauses until a required condition is met. Use a wait node to create a reaction to a database event, such as a status change, or a record update. A process can have one or more wait nodes. You do not need to include wait nodes in a process. A wait node cannot precede a node that requires user interaction, such as an interaction node or a manual input node.
One or more positive
lines; one or more
negative lines.
One positive line is
required.
Stop node

Marks the end of a workflow process. That is, the point where a record leaves control of the process. When you create a process, a single stop node is placed on the canvas. Use the stop node tool in the palette to place additional stop nodes on the canvas.
One or more positive
lines; one or more
negative lines.
None.

For this example I want the user to get an Inbox assignment. From this assignment he needs to evaluate the record and either approve it or cancel it.

Looking in the table I want to use a 'Task node'

First I open the 'Workflow Designer' (Go-To -> System Configuration -> Platform Configuration -> Workflow Designer)

Then I create a new Workflow Process, give it a name, description, and since I am using it on a Clones application of SR, use SR as the object:



Save the Process.

Next I drag a Task Node onto the canvas.



Then I grap the "Connect Nodes" pencil and drag a line between the Start node and the Task node, and a line between the Task node and the Stop node.



Then I drag a "Negative" line from the Task Node to the Stop Node.



The connections I created are 'Actions' in Workflow. To modify a Action, I simply double click on the positive (black) arrow between the Task node and the Stop node.

The "Action" properties pop-up and I fill it in like so:



Then I double click the negative (red) arrow and fill it in:



I save the Process

Next I want to configure what group of users is assigned to this task.
I double click on the Task node and fill it in like shown below:



Mind the Application fields! I use a clone of SR, so I need to make sure it is changed here.

Next I do the following steps fro mthe 'Select Action' menu: 

  • Validate Process
  • Enable Process
  • Activate Process


I save the record.



Step 5 - Test the workflow

I create a new record in my cloned application, save it and click the "Route Workflow" button:





Now I log out, and log back in as the PIAPPR user, that is linked to the PIAPPR person referenced in the PIAPPR person group.

This user has an Inbox configured, and I configured some fields in this Inbox:



There are two options to click on in this Inbox, Either click on the description, the record will open. You can view it, and if you want you can click the "Route Workflow" icon from there to open the "Workflow Assignment" dialog

Or click on the "Route Workflow" icon, to open the record and directly open the "Workflow Assignment" dialog.

In the "Workflow Assignemnt" dialog I can choose from the actions I configured in the Workflow:



After choosing one of the options, the workflow ends and the status is changed:




So there it is, a very basic Workflow. 

GNZ