how to write parser expressions updating fields with automation rules

Trond Meistad January 11, 2022

What should the syntax be for updating fields using smart values in automation rules?

I am using an on-premise version of Jira.

I have written a rule that is triggered when a comment is added.

In this simplified example I want to add the last comment concatinated to the description field.
In the end I will use instr() and indexof() functions to get a provider case number from the comment field and add it to the name field.

What works is adding the comment as it is to the description.
Using basic parsing mode the parser expression is this:
%{trigger.issue.lastComment}%{trigger.issue.description}


What does not work and what I want to achieve is this:
%{trigger.issue.description.concat(trigger.issue.lastComment)}

Also tried different versions
%{trigger.issue.description}.concat(trigger.issue.lastComment)
{{trigger.issue.description.concat(trigger.issue.lastComment)}}
{{trigger.issue.description}.concat(trigger.issue.lastComment)}

What I now see in the description is the parser description itself.

What should the parser expression look like?

3 answers

1 vote
Max Foerster - K15t
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 19, 2022

Hi @Trond Meistad!

You're indeed using the automation rules of our product Jira Workflow Toolbox, so let me help you in getting that automation rule up and running. :) To simply add the last comment to your description, you can use the following expression. I also added a line break

%{trigger.issue.description}
+ "
"
+ %{trigger.issue.lastComment}

Please make sure to switch to the "Advanced text" parsing mode. It enables you to easily combine field codes with plain text in quotation marks "" and the + operator. 

From here you could even add further information and add the user name of the last commenter, a timestamp, and much more. Here's a little example:

%{trigger.issue.description}
+ "
"
+ "Comment posted by "
+ %{trigger.issue.lastComment.author}
+ " on "
+ %{system.currentDateTime}
+ ": \""
+ %{trigger.issue.lastComment} + "\""

And the result will look something like this:

 atl_community.png

You can find a more detailed explanation and use cases in our document about the Advanced text parsing mode. Our app documentation is available on https://apps.decadis.net 

Please let me know if you have additional questions!

Best, Max

0 votes
Trond Meistad January 14, 2022

This is the first time I work with Jira, but I am quite certain we use Automation for Jira. I have added a larger screenshot that shows this.

We are using an on-premise version 8.8.0

AutomationRuleQuestionLarge.PNG

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 11, 2022

Hi @Trond Meistad -- Welcome to the Atlassian Community!

Would you please post an image of your complete rule?  That may provide context for the community to offer suggestions.  Thanks!

Until then...Please take a look at documentation for the available smart values for Jira Server/Data Center, automation.  That may help.

https://confluence.atlassian.com/automation/using-smart-values-993924627.html

For example, the last comment's body from the trigger issue is:

{{triggerIssue.comments.last.body}}

 

Kind regards,
Bill

Trond Meistad January 12, 2022

Hi.

If I type {{triggerIssue.comments.last.body}}, the text gets a black font color and is added as {{triggerIssue.comments.last.body}} text in the description field. Obviously it is interpreted as plain text.

AutomationRuleQuestion2.PNG

This is what it looks like when a comment is added

AutomationRuleQuestion2Result.PNG

Here is the rule definition. In the final rule it will be string operations that will pick up the case number that always starts with "AB-" and add it to the end of the Jira case name.

AutomationRuleQuestion.PNG

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 12, 2022

My apologies as I thought you were using Automation for Jira (the Lite or Pro version).

I am not using the Server/Data Center version and so did not recognize your tool, and instead you appear to be using something else to perform the automation.

What are you using to create the automation?

Trond Meistad January 17, 2022

This is the first time I work with Jira, but I am quite certain we use Automation for Jira. I have added a larger screenshot that shows this.

We are using an on-premise version 8.8.0

AutomationRuleQuestionLarge.PNG

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 18, 2022

Looking at your image, you are using the Jira Workflow Toolbox's version of automation, and not the Automation for Jira app.

I have no experience with that tool, and I recommend taking a look at this documentation for the tool to see what you can find: https://marketplace.atlassian.com/apps/29496/jira-workflow-toolbox?tab=support&hosting=server

Like Max Foerster - K15t likes this

Suggest an answer

Log in or Sign up to answer