Introduction to Workflow Programming

This chapter discusses the following:

Programming CM Scripts

As you have seen in the previous sections, ConSol Workflows can be set-up rather easily using the Process Designer's graphical interface. However, in order to bring "real intelligence" into workflows, programming, i.e. writing ConSol CM workflow scripts which are used in the workflow activities and preconditions, is required.

ConSol CM scripts are written in Groovy, so you should have at least basic knowledge of this programming language. Since Groovy code runs in the Java Virtual Machine, you can also write Java code. Thus, if you are a Java or Groovy developer, it will be easy for you to learn how to build sophisticated workflows using the ConSol CM Groovy API.

If you are interested in the Groovy training Groovy in a Nutshell provided by ConSol, please ask your CM sales representative.

In the current manual, we use Java style and Groovy style. You can decide which way to follow.

Some Short Examples of Java vs. Groovy-Style Coding

As mentioned above, you have to use Groovy for ConSol CM scripts. There might be different possibilities to express or code the same content. In the following paragraphs, we will give you some hints and provide some examples how to work with the Groovy API.

Getter Methods Can Often Be Omitted

Most Groovy objects possess numerous getter methods to retrieve values from object attributes. You can either use the complete getter methods, or you can use the short (convenience) form. Please see the following examples for workflow scripts.

Use Case Java-like syntax (extended version) Groovy syntax (short version)
Get the subject of a ticket. String mysubject = ticket.getSubject() def mysubject = ticket.subject
Get the engineer of a ticket. Engineer myeng = ticket.getEngineer() def myeng = ticket.engineer
Get the main contact of a ticket. Unit mymaincontact = ticket.getMainContact() def mymaincontact = ticket.mainContact
Get the value of a certain Custom Field from a ticket. String myprio = ticket.get("helpdesk_fields", "prio") def myprio = ticket.get("helpdesk_fields.prio")
Get the unit type for the primary contact.

Unit mycustomer = workflowApi.getPrimaryContact()

UnitDefinition myunitdef = mycustomer.getDefinition()

UnitDefinitionType mydeftype = myunitdef.getType()

def mycustomer = workflowApi.primaryContact

def myunitdef = mycustomer.definition

def mydeftype = mycustomer.definition.type

Access to Custom Fields cannot be shortened, because there are no getter methods for those fields. Please read the section Working with Data Fields for details about working with data from Custom Fields.

Setter Methods Can Often Be Omitted

Most Groovy objects possess numerous setter methods to set values for object attributes. You can either use the complete setter methods, or you can use the short (convenience) form. Please see the following examples for workflow scripts.

Use case Java-like syntax (extended version) Groovy syntax (short version)
Set the subject of a ticket. ticket.setSubject("asd") ticket.subject = "asd"

CM API Documentation

A Groovy API Doc is provided for the ConSol CM API. Please ask your ConSol CM consultant or sales representative if you would like to receive the respective .jar file.

Figure 116: ConSol CM Groovy API Doc

CM Script Types in Workflows

In ConSol CM workflows, scripts are used in the following contexts:

Please refer to the respective sections in this manual for an explanation how to insert the scripts.

Script Interactions

For each workflow script, you can decide if the code should run directly in the workflow or if the script should be stored in the Admin Tool, section Scripts and should be called from the workflow script. See section Store Some Workflow Scripts in the Admin Tool for details.

Scripts in ConSol CM in General

Please keep in mind that the configuration and programming using the Process Designer make up only "half-the-intelligence" of your ConSol CM system! Numerous configurations and scripts are managed using the Admin Tool! As far as scripts are concerned, please read the section about Admin Tool Scripts in the ConSol CM Administrator Manual.