Create a Checklist based on checked items of Custom FIeld
Asked by Alexis:

Hi, I have a Form that I use to attach to an issue on JSM. This form has a Custom Field, which is a list of checkable Items (e.g. Custom Field of Softwares, with each software a single checkbox item).

I would like to automate the creation of a Checklist, based on the selected/checked values of the Custom Field. Preferably in a new Task or Subtask that is associated with the original Issue.

For example, if a user raises an Issue, the Form with the Custom Field of Software is attached. The user then selects the relevant software(s) and commits the Form. Right after that a Task or Subtask is created and has a Checklist with all selected softwares.


Answers:
author: Darryl Lee
body: Hi [@Alexis](/t5/user/viewprofilepage/user-id/4152524) --

I love this idea. Unfortunately Atlassian does not have a native Checklist function available. I messed around and created a Table using the :black_square_button: emoji, but they aren't truly "checkable":

![Screenshot 2023-12-09 at 2.09.09 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/296037i6322C132B5D00FEB/image-size/large?v=v2&px=999 "Screenshot 2023-12-09 at 2.09.09 PM.png")

(I also figured out how to programmatically create such a table, but it is... ugly, involving making a Web Request to the REST API and hacking together JSON.)

I wonder if you already have a Checklist add-on or are thinking of getting one, like [Checklist for Jira Cloud](https://marketplace.atlassian.com/apps/1223660/checklist-for-jira-cloud-free?hosting=cloud&tab=overview&m=enttofree), or [Issue Checklist for Jira](https://marketplace.atlassian.com/apps/1220209/issue-checklist-for-jira-free?hosting=cloud&tab=overview) or [Checklist for Jira](https://marketplace.atlassian.com/apps/1211562/checklist-for-jira?hosting=cloud&tab=overview) (OOOF, [there are a lot of these.](https://marketplace.atlassian.com/search?hosting=cloud&product=jira-service-management&query=checklist))

If so, it seems like most of those provide some mechanism for automatically creating Checklists. It would then be a matter of parsing your Form, which .... ooof, is a little complicated (and officially unsupported):

[JSDCLOUD-10697 - Forms Automation: Access form fields with smart values (smartvalues)](https://jira.atlassian.com/browse/JSDCLOUD-10697)
> ... the [documentation](https://confluence.atlassian.com/proforma/automation-for-jira-server-1087520919.html) for Server/DC under the heading **Access the contents of ProForma Forms,** relating to entity properties also applies to cloud; however, be aware accessing form data this way is not officially supported.

Oooh nellie, yeah, that's a lotta work:

* [Access the contents of ProForma Forms](https://confluence.atlassian.com/proforma/automation-for-jira-server-1087520919.html#AutomationforJira(Server)-AccessthecontentsofProFormaFormsRedWARNING)

OH! I guess this is slightly good news: [JSDCLOUD-10671 - REST API for ProForma/Forms in Jira](https://jira.atlassian.com/browse/JSDCLOUD-10671) has been resolved, which means that instead of hacking around in issue properties, there's a [REAL API for Forms](https://developer.atlassian.com/cloud/forms/rest/intro/) that you could query.

Now... this doesn't make Automation too much easier, since you'll still need to use [Web Requests to access the REST API](https://confluence.atlassian.com/automationkb/how-to-extend-automation-for-jira-with-rest-api-calls-1021217952.html) and then parse out the responses, but uh, I guess you don't have to use to use the Console as much to figure out your Form fields?

UGH, actually, in retrospect, it'd probably be easier just to use the old workaround:

* [Reading a Forms(ProForma) field value without the JSON tab](https://community.atlassian.com/t5/Jira-Service-Management-articles/Reading-a-Forms-ProForma-field-value-without-the-JSON-tab/ba-p/2097012)

As usual, I've probably given you more info than you wanted to know. :-}

LMK if you have any questions.

comments: author: Alexis
body: I'm trying it with Issue Checklist for Jira Free, but I still struggle with getting the automation. [Add Checklist Based on a Custom Field Value (herocoders.com)](https://docs.herocoders.com/checklist/add-checklist-based-on-a-custom-field-value)

Do you have some experience with that addon? because when I try the automation, I get a textfield with the text, but no checklist?

Or, do you have a recommendation for a checklist addon?


author: Darryl Lee
body: Ah, so yeah, the issue (probably) is that you're using a Form.

By default, Form Fields are not linked to Custom Fields (and from the documentation, Issue Checklist for Jira Free creates a new field called **Checkbox Text**).

So *ideally* what you could do is link the Checkbox field in your form to the **Checkbox Text** field created by the add-on.

UNFORTUNATELY, despite appearing to be a somewhat regular custom fields, it looks like Atlassian does not consider **Checklist Text** to be a"normal" field, and so it is not available to link to:

![Screenshot 2023-12-11 at 3.33.40 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/296269iC105A6C9206DBE53/image-size/large?v=v2&px=999 "Screenshot 2023-12-11 at 3.33.40 PM.png")

![Screenshot 2023-12-11 at 3.28.05 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/296267i9E9F14EE5A435AEC/image-size/large?v=v2&px=999 "Screenshot 2023-12-11 at 3.28.05 PM.png")

I also thought there might be a workaround by using an intermediary Paragraph/Multi-line Text custom field and copying the data, but Atlassian will not let you link a Checkbox form field to a Paragraph/Multi-line Text custom field:

![Screenshot 2023-12-11 at 3.28.20 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/296272i5C7633B77FBAD2F0/image-size/large?v=v2&px=999 "Screenshot 2023-12-11 at 3.28.20 PM.png")

So that probably would've blocked the **Checklist Text**idea too.

HUM.

So this will probably call for some hackery as mentioned [before](https://community.atlassian.com/t5/Jira-Service-Management-articles/Reading-a-Forms-ProForma-field-value-without-the-JSON-tab/ba-p/2097012), digging out the checkbox values from the Issue Properties, and then doing something like editing the Checkbox Text field with something like:

```
{{#if(issue.properties."proforma.forms.i1".state.answers.18.choices.join(",").match(".*\b1\b.*"))}}* [open] Foo
{{/}}{{#if(issue.properties."proforma.forms.i1".state.answers.18.choices.join(",").match(".*\b2\b.*"))}}* [open] Bar
{{/}}{{#if(issue.properties."proforma.forms.i1".state.answers.18.choices.join(",").match(".*\b3\b.*"))}}* [open] Bat
{{/}}
```

ALAS, THIS DOES NOT WORK.

Could I phone a friend, ([@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)? Any thoughts on why my **if**statements are coming up empty? I did some testing:  

```
RAW: {{issue.properties."proforma.forms.i1".state.answers.18.choices}}
```

Audit Log: RAW: 1, 3  

```
JOIN: {{issue.properties."proforma.forms.i1".state.answers.18.choices.join(",")}}
```

Audit Log: JOIN: 1,3  

```
MATCH: {{issue.properties."proforma.forms.i1".state.answers.18.choices.join(",").match(".*\b(1)\b.*")}}
```

Audit Log: MATCH:

And yes, I even tried trying to iterate through all the choices, but I'm pretty sure it's not possible to match against {{.}}.


author: Darryl Lee
body: Where my form checkboxes are Foo, Bar, and Bat, and [examining the issue properties](https://community.atlassian.com/t5/Jira-Service-Management-articles/Reading-a-Forms-ProForma-field-value-without-the-JSON-tab/ba-p/2097012) reveals them to be question 18, with ids of 1, 2, and 3, respectively:

```
{ 
...
 ?"state": {
    "visibility": "i",
    "status": "s",
    "answers": {
...
      "18": {
        text": "",
        "choices": [
          "1",
          "2",
          "3"
        ]
      }
    }
  }
}
```


author: Alexis
body: Yeah, I tried something similar, but it seems it goes back deeper.

If I input manually or automate to fill the Checklist Text with the "\* format" then exactly this text will be written to the Checklist Text Field, but no actual Checklist Element appears. If I manually press the "Add Checklist" Button atop of the issue, a new Checklist comes up - seemingly totally separate the the Checklist Text field, because the Checklist Element is just empty.

When automating I also had to go to the Issue Configuration, and manually enable/drag the Checklist Text field in. If I don't do that, I get an Error on the Automation that the customfield 10081 is not available.

But, regardless, even if the field is on the issue, it seems not to change the actual Checklist


author: Bill Sheboy
body: Hi [@Darryl Lee](/t5/user/viewprofilepage/user-id/1365322) and [@Alexis](/t5/user/viewprofilepage/user-id/4152524)

I have been following this thread as the use case seems interesting and helpful, if it turns out to be possible :\^)

Darryl, on your note about "alas, this does not work", I could guess 2 possible causes:

1. Please note the automation rule, regular expression implementation is documented as ["based on Java's Pattern class"](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#match--), yet there is no documentation of what does (and does not) work. Added with the nuances in the behavior of match()...it may not be matching anything. The way to test that: add a split(",") immediately after that join() to reduce the scope the match is checking.
2. Some smart values are dynamically sourced (e.g., from some marketplace addons). As a result they can be read but often not used in more complicated, smart value expressions. The work-around for that is to first store the "read" value in a created variable, which does the dynamic lookup and saves it as text. Then use that created variable in your expression. Unfortunately, this removes any typing information, so a work-around for that is to instead store it in a Lookup Table row value as that does save objects.

Kind regards,  
Bill


author: Darryl Lee
body: Hi [@Alexis](/t5/user/viewprofilepage/user-id/4152524) - yeah updating the **Checkbox Text** wasn't working for me either UNTIL I looked more closely at the directions:
> 1. Ensure the [**Save local checklist items to Jira custom fields**](https://docs.herocoders.com/checklist/configure-checklist-global-settings) global setting is enabled..

Once I toggled that, I could create a standalone action of Editing the issue and updating the **Checkbox Text** field and it updated my checklist.

I didn't have to add the field to the screen. Is this a Company- or Team-managed project?


author: Darryl Lee
body: Great to hear from you [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) ! Yeah, I guess I got too fancy with my regex. Also, I neglected to do incremental debugging:

Here's my Audit log tests:

```
SIMPLE WILDCARD CAPTURE MATCH: {{issue.properties."proforma.forms.i1".state.answers.18.choices.join(",").match(".*(1).*")}}

EQUALS: {{issue.properties."proforma.forms.i1".state.answers.18.choices.join(",").match(".*(1).*").equals("1")}}

IF: {{#if(issue.properties."proforma.forms.i1".state.answers.18.choices.join(",").match(".*(1).*").equals("1"))}}* [open] Foo {{/}}
```

And the results:
> SIMPLE WILDCARD CAPTURE MATCH: 1
> EQUALS: true
> IF: \* \[open\] Foo

Woot, so we are in business! Hopefully [@Alexis](/t5/user/viewprofilepage/user-id/4152524) doesn't have more than 9 checkboxes, because the match for "1" is going to match "10-19" too:

```
{{#if(issue.properties."proforma.forms.i1".state.answers.18.choices.join(",").match(".*(1).*").equals("1"))}}* [open] Foo
{{/}}{{#if(issue.properties."proforma.forms.i1".state.answers.18.choices.join(",").match(".*(2).*").equals("2"))}}* [open] Bar
{{/}}{{#if(issue.properties."proforma.forms.i1".state.answers.18.choices.join(",").match(".*(3).*").equals("3"))}}* [open] Bat
{{/}}
```

#### ++**ATTENTION REGEX DANGER**++ {#toc-hId-291475562}

So you might think you could search for: .\*(1),.\*, but you would be forgetting that also matches 11, 21, 31. This is why I really needed \\b (word boundary). I also tried \\D, and even the old school \[\^0-9\] and they were all no-go.)

Now, [last year](https://community.atlassian.com/t5/Jira-Service-Management/Is-it-possible-to-match-over-multiple-lines-using-a-regex/qaq-p/2162350#M117735) in October [@Yvan Martin](/t5/user/viewprofilepage/user-id/3630079) wrote:
> Currently the regex expressions in Automation are using Java pattern matching. So when trying out expressions is best to use one that you can select the Flavour of Java e.g. [https://regex101.com/?flavor=java\&flags=g](https://regex101.com/?flavor=java&flags=g). The reason \^ and $ aren't working is by default multiline is being turned off (you can simulate that in that regex link). So you need to use the manual way of turning it on which is putting (?m) at the start of the regex.

So yeah, if it was using the [FULL Java regex class](https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html), then this query should've worked:

```
BOUNDARIES: {{issue.properties."proforma.forms.i1".state.answers.18.choices.join(",").match(".*\b(1)\b.*")}}
```

I successfully tested it in the regex tester he recommended: <https://regex101.com/r/WaBuuJ/2>

And I think it should've returned Group 1, which contains 1. But since the example for [**match**](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#match--) shows it returning what looks like an array or list \[o, o\], then ok, this should've worked, right?  

<br />

```
BOUNDARIES FIRST: {{issue.properties."proforma.forms.i1".state.answers.18.choices.join(",").match(".*\b(1)\b.*").first}}
```

<br />

Nope. Nada.

So tell us Yvan, is Bill right, [when he writes](https://community.atlassian.com/t5/Jira-Software-questions/Regular-Expression-in-Automation-Rule-in-JIRA/qaq-p/2386536#M272010):

<br />

<br />

> First thing: the [rules documentation around regular expressions](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#match--) states it is "based on Java's Pattern class", and others have found not all of the features from that spec work. I find only experimentation confirms what does and does not work.

Because it would REALLY be nice if we didn't have to spend hours testing. I mean, not that I don't \*LOVE\* debugging. :-P


author: Alexis
body: [@Darryl Lee](/t5/user/viewprofilepage/user-id/1365322) Setup-wise I *think* everything is correct, I also had the option for local checklist items already set. The project is company-managed, and it is a Service Project from JSM.

Did the field just appear automatically for you? So, if you go to a relevant issue and check the Dot Menu "Find your field", do you have any errors when searching for "Checklist Text"? Can you see the field in a tb or on the More Fields view on the right of the issue?


author: Darryl Lee
body: So, **Checklist Text** is not a normal field, so I don't think it's *supposed* to be visible in issue views.

I believe the vendor makes it visible to Automation so that you can programmatically set it, and it will show up as in the vendor's Checklist section of Jira.

I am Editing it with Automation:

![Screenshot 2023-12-13 at 4.15.04 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/296747i310763DE29D008AB/image-size/large?v=v2&px=999 "Screenshot 2023-12-13 at 4.15.04 PM.png")

And putting my smart value hackery here:

![Screenshot 2023-12-13 at 4.16.17 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/296748i1F0753CE2D127A8E/image-size/large?v=v2&px=999 "Screenshot 2023-12-13 at 4.16.17 PM.png")

And here's what I ended up with:

![Screenshot 2023-12-13 at 10.00.01 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/296767i3EC0F76E7CA0F7ED/image-size/large?v=v2&px=999 "Screenshot 2023-12-13 at 10.00.01 PM.png")

(I find it fascinating that it shows the timestamp of when my Automation ran. That's a neat feature!)


author: Adaeze_Jude_HEROCODERS
body: Hi [@Alexis](/t5/user/viewprofilepage/user-id/4152524)

The Checklist Text custom field allows you to manipulate the Checklist using automation. You are able to set the Checklist based on certain field conditions using the Checklist Text field in automation. You would need to make sure that you have the "**Save local checklist items to Jira custom fields"** global setting enabled. This allows the values of the custom field to sync with the actual Checklist UI. You can add this field to the edit issue screen to view your Checklist in Text format.

If you still need help setting this up Kindly reach out to us [here](https://herocoders.atlassian.net/servicedesk/customer/portals).


author: Oleksandr Siryi_Railsware_
body: Hey, [@Alexis](/t5/user/viewprofilepage/user-id/4152524)

Have you considered an app like [Smart Checklist](https://marketplace.atlassian.com/apps/1216451/smart-checklist-for-jira-pro?hosting=cloud&tab=overview)? It can help with automatically creating checklists in issues. However, this will only help with the second part of your question...

comments: author: Alexis
body: I was trying Issue Checklist for JIRA, but sofar it won't work, but I will take a look at Smart Checklist too.


author: Olena Brazhko_Railsware_
body: [@Alexis](/t5/user/viewprofilepage/user-id/4152524) hi!

If you need specific help with setting up Smart Checklist, you are welcome to contact the Support Team at [support@titanapps.io](mailto:support@titanapps.io).

Best,

Olena


author: Alexis
body: Hi [@Olena Brazhko_Railsware_](/t5/user/viewprofilepage/user-id/4437823)

I tried out Smart Checklist, and the syncing works like a breeze. Amazing.

I created the custom fields, and in my automation I populate the "Checklists" field with the stuff from the form like this

```
{{#issue.Services}}- {{value}}\\{{/}}
```

the "\\\\" normally creates a new line. In Automation, if I use that for the "Description" field, it works like expected, creating a normal list with one item per line.

But the same approach leads to the Checklists field having this value:

```
- SoftwareA\\ - SoftwareB\\ - SoftwareC\\
```

Which leads to the Checklist component having only one item, which is

```
SoftwareA\ - SoftwareB\ - SoftwareC\
```

What can I do to make a new line? I tried \\n and \<br\> but it seems not to work.


Tags: checklist

forms

jira-service-management