Using JMWE Set Field to update an existing field for HeroCoder's Issue Checklist Pro

Abel Lineberger April 21, 2023

So am trying to combine the JMWE Set Field function with HeroCoder's Issue Checklist Pro functionality.

The goal is to dynamically build an ongoing checklist of actions as an issue progresses through the workflow as a series of post-functions.

I am using the Checklist Text field to add formatted checklist items to the "Checklist".

I attempted to use the standard Jira update custom field function but when you use the append option Jira automatically inserts a blank line, which Issue Checklist Pro interprets as a new checklist... it gets ugly.

My thought is to use the JMWE Set issue fields post-function to:

  1. Query the current values of the checklist 
  2. Append to that value the new checklist item(s) if necessary rewriting the whole field.

Issue Checklist Pro uses the following formatting:

# Default Checklist
* ---HR Checklist
* [open] Send Welcome Letter
* [open] Send SWAG

* --- denotes a header 

The goal is to add additional lines following the structure above, with no additional line breaks.

So after the second transition, the field might look like:
# Default Checklist
* ---HR Checklist
* [closed] Send Welcome Letter
* [closed] Send SWAG
* [open] Do the next thing

I do need to keep the updated statuses of the work in progress, which is why I was thinking about querying the contents prior to updating them.

Thoughts?

3 answers

2 accepted

1 vote
Answer accepted
Abel Lineberger April 21, 2023

And resolved:

Don't need to use the  Build-your-own (scripted) Post-Function from JMWE, just use the Set issue fields function.

Use the same script developed above:
{% set checklist = issue.fields.customfield_10073 %}
{% set items = [checklist, '* [open] Do the next thing', '* [open] Do the next next thing'] %}
{{items | join("\n")}}

And you can add as many of the '* [open] Do the next thing', as you like.

There is a small delay before the checklist is updated, but it does so dynamically, so no need to for the user to refresh the screen.

0 votes
Answer accepted
Wojciech Wardaszko _HeroCoders_
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.
April 22, 2023

Hi @Abel Lineberger

I'm glad that you have this sorted out, although I'm surprised to read that editing the Checklist Text field with a post function adds an unwanted empty line to the field. I have just tested it and have not observed similar behavior, see the screenshots below:

checklist post function add item.png

and the result in Checklist Text field:

checklist post function add item - result 1.png

and in the app's UI: checklist post function add item - result 2.png

I'd like to learn more about your setup to try and solve the core issue for you.

As for workarounds, there is another one that does not require any other apps - with Jira Automation.

The rule is simple:
Trigger - Transition issue (any setup that suits your needs here)

Action: Edit Issue: Checklist Text field.

In the Checklist Text we put:
{{issue.Checklst Text}}
--- test header
* [] new item to add with Automation
>> a description for that new item if needed
* [] another item, due on {{now.plusDays(14).jiraDate}}
* [] yet another item assigned to @{{issue.reporter.id}}

The additional items are here just to highlight how much can be done with Automation and Checklist Text.

We put the {{issue.Checklist Text}} smart value at the top so all that follows is appended and does not replace what was previously there.

Please let me know more about your issues with the post function. Feel free to reach out to us via our service portal if you'd like to discuss it in detail.

Cheers!

Abel Lineberger April 24, 2023

@Wojciech Wardaszko _HeroCoders_ thanks for the catch!  My mistake in reporting, I was updating the YAML block, not the text block.

Thanks for pointing out the use of {{issue.Checklist Text}}.

Abel Lineberger April 24, 2023

@Wojciech Wardaszko _HeroCoders_ and this is on a Jira Work Management project to add another layer of complexity...

Wojciech Wardaszko _HeroCoders_
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.
April 26, 2023

I don't think this complicates anything, unless it's a team-managed (aka next-gen) project?

In that case some of our custom fields are unavailable at this time... bummer.

0 votes
Abel Lineberger April 21, 2023

Using JMWE's Build-your-own (scripted) Post-Function I have managed to get the new items added using the following script:

{% set checklist = issue.fields.customfield_10073 %}
{% set items = [checklist, '* [open] Do the next thing', '* [open] Do the next next thing'] %}
{{items | join("\n")}}

But now am trying to figure out how to update the field with the joined set.

Suggest an answer

Log in or Sign up to answer