Sometimes you use Jira for order tracking. In a typical setup, a single Jira issue represents an order, which may contain multiple line items (such as products, quantities, prices).
When order details are stored in a single, multi-line text custom field (e.g., customfield_cforders), effective reporting becomes challenging. You cannot easily analyze orders by product or sum values because all the data is in one text block. Let’s try to address this challenge.
Let’s assume that you have order data in customfield_cforders and your data has a predefined structure, with one item per line:
Format: OrderID,ItemID,ItemValue
Example data:
ORD-101,ITEM-A,150.00
ORD-101,ITEM-B,75.50
ORD-102,ITEM-A,200.00
To accommodate the structure, first step is to create necessary dimensions that will held the Order ID and Item ID:
[jira.customfield_orderid]
name = “Order ID”
data_type=“string”
split_by = “,”
dimension=true
separate_table=true
[jira.customfield_itemid]
name = “Item ID”
data_type=“string”
split_by = “,”
dimension=true
separate_table=true
The next step is to create a custom field that will held the Item Value and add Javascript that will return comma - separated field value with normalized line endings.
[jira.customfield_ordervalue]
name=“Order Value”
data_type=“decimal”
measure=true
multiple_dimensions=[“Order ID”,“Item ID”]
split_by = “,”
javascript_code=‘’’
if (issue.fields.customfield_cforders){ var recs = issue.fields.customfield_cforders.split(/\r?\n/); return recs.join(“\n”); }
‘’’
Note: If you have users that still works on OS that supports CR - style line endings, you will need to modify the Javascript accordingly.
If you want to have additional measures (for example Item Count), you need to define custom field that will held this measure and update Javascript accordingly. I am always placing the custom field with Javascript as the last field. Also, if you want to measure your orders over time, you need to add “Time” dimension in your value fields and update Javascript accordingly (this is pretty well documented in eazyBI documentation - just search for multiple_dimensions).
Special thanks to Mārtiņš Vanags for helping to figure out this.
Important notes
The JavaScript provided in this example assumes that the content format in customfield_cforders is always valid. The best place to perform data validation is within Jira itself, for example, using a custom status transition validator or a workflow post-function. This ensures data integrity before it reaches eazyBI.
Also, this might be relevant to this old thread, however as it is 2+ years old and in Q&A category, decided to proceed with the new post.
Hope someone will find this information useful.