The following are some of the basic principles and concepts of Ruby. Examples are included to help illustrate. Basic documentation for Ruby can be found at: http://www.ruby-doc.org/core/
The Kinetic Task Engine has been developed using Ruby, and as developers and administrators, we have the ability to add ERB (Embedded Ruby) when configuring Task Nodes and Connectors.
Task Engine templates are configurable sections of text that are capable of substituting in various engine variables. See Appendix B for a description of each template.
Listed below are the Template Variables commonly used:
@answers, @appconfig, @base, @dataset, @template, @results
These Template Variables are visible when configuring Task Nodes and Connectors.
Within the engine, multiple variables are available to help control process flow. There are two places that these engine variables, also referred to as bindings, are used. The first is in templates by the Task Builder, and the second is within a task handler's process/node.xml file. See Appendix B for a description of available variables.
Using in a Task Node
When configuring a Task Node, you will see the variables related to a template after you select one of the templates from the menu.
After a Template and Variable value has been selected from the menu, you see a statement like this added to the Value field on the Task Node.
<%=@answers['Req Email Address']%>
Opening and closing template tags
Will render the result returned from the embedded Ruby expression as text
Name of the template selected (identifies the source of the data for the Task Engine)
['Req Email Address']
This is the variable name. Since the @answers template was selected, this is the menu label name of the question.
Sample Expressions for Nodes
Uses Remedy Date/Time field and converts it to an ISO format
Grab the first 255 characters from an answer
@values['Comments'].slice(0,255) unless @values['Comments'].nil?
You can also do If statements
<% if @answers[' Request Type'] == 'Transfer'
Use for Remedy ENUMs
Sample Expressions for Connectors
This expression will exclude organizations beginning with afp and dia
<%= (Regexp.new("^(afp|dia).*$",true) =~ @answers['ReqFor Organization']).nil? %>
#Will include organizations beginning with ait
#The " || false " at the end is needed because if the regex test doesn't match, it returns nil - which will cause the eval to crash.
<%= Regexp.new("^ait",true) =~ @answers['Q1'] || false %>
#This checks for values that are not like "afp"
(Regexp.new("^afp.*$",true) =~ @answers['ReqFor Organization']).nil?