Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Creation decision table using Camunda Modeler

For instruction instructions on how to create a DMN decision table in Camunda Modeler, please check: https://docs.camunda.org/get-started/quick-start/decision-automation/#create-a-dmn-table-using-the-camunda-modeler

Adding decision table file to Jira

In the current version, the add-on supports decision tables saved as in Camunda format (.dmn) which you could prepare in the Camunda Modeler application. To use them, put them into the plugin folder on your jira Jira server:

  1. Go to the JIRA HOME directory.
  2. If you can't find  the decision_tables directory, create a new one.
  3. Go to the decision_tables directory.
  4. Put there your decision table files.

Using decision table in a groovy script

Let's use a known to us example:

Additionally, let's assume we can save cost as an issue in our Jira - columns correspond to custom fields. Based on that it can be concluded, who will be responsible and set that in an appropriate field. Using Decision Table for Jira add-on we can do that with such script in ScriptRunner Console.

...

Of course, you don't want to execute Decision Tables for Jira functionalities manually, but use them to automatize your business processes. So let's look at other another example, where we want to automatically set that approver as an assignee to that issue. Such script can be used as a postfunction post-function on your workflow.


Code Block
languagegroovy
themeRDark
firstline1
linenumberstrue
def customFieldManager = ComponentAccessor.getCustomFieldManager()

// get involved custom field references
def costTypeCF = customFieldManager.getCustomFieldObjectsByName("Cost Type").first()
def costCentreCF = customFieldManager.getCustomFieldObjectsByName("Cost Centre").first()
def amountCF = customFieldManager.getCustomFieldObjectsByName("Amount").first()

// get field values
def costType = (Option) issue.getCustomFieldValue(costTypeCF)
def costCentre = (Option) issue.getCustomFieldValue(costCentreCF)
def amount = (Double) issue.getCustomFieldValue(amountCF)

// get DecisionTableManager which is an OSGI component in the Decision Tables plugin
@WithPlugin("eu.rivetgroup.atlas.rvg-jira-decision-tables-plugin")
@PluginModule
DecisionTableManager decisionTableManager

// build a decision table query, fill input parameters values
def dtQuery = [
	"costType": costType.value, // single choice option filed - we pass an option value
	"costCentre": costCentre.value, // single choice option filed - we pass an option value
	"amount": amount // numerical value - use the value directly
]

// execute the decision table query
def dtResult = decisionTableManager.getDMNDecisionTableOperations(
	"costDecisions", // name of the DMN file without the file extension (dmn)
	"costDecision" // id of decision table element inside DMN model (DMN can contain multiple decision tables)
).executeQuery(dtQuery);

// get returned entry from the result
Map<String, ?> dtResEntry = dtResult.singleNonEmpty();

// we get user name of approver
String approverName = dtResEntry.get("approver")

def approverUser  = ComponentAccessor.getUserManager().getUserByName(approverName)

// set assginee as approverUser
issue.setAssignee(approverUser)

...