Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Check/uncheck Checklist options (okapya) with ScriptRunner behavior

Edited

Hello, In Jira Server/Data Center we have Checklist plugin installed (okapya). We have a lot of automation based on ScriptRunner/Groovy: make custom fields read-only or hidden, select value or add new options into the select list custom field based on the value in the other custom field.

We also need possibility to manage Checklist behavior with help of ScriptRunner Behaviours on Create/Edit Screens.

Currently request which I got is very simple:

  1. Set several Checklist options "checked" based on the other custom field value on Create/Edit Screen.
  2. Also I need to make Checklist field read-only or writable based on the value of the other custom field on Create/Edit screen.
  3. Another request is to make all options in Checklist read-only except one particular option on Create/Edit screen.

I tried just simple case: created ScriptRunner Behavior to make Checklist field read-only, but it didn't work - checklist is still editable and I can check/uncheck options.

Behavior.PNG

Some quick server-side script I tried in ScriptRunner Behavior for the Checklist custom field:

import com.onresolve.scriptrunner.runner.customisers.WithPlugin
@WithPlugin("com.okapya.jira.checklist")
import com.okapya.jira.customfields.*
import com.okapya.jira.checklist.*

def checklistField = getFieldById(fieldChanged)

Collection<ChecklistItem> items = (Collection<ChecklistItem>) checkboxField.value
items.find(item -> item.getName() == "Help").setChecked(true)

But it doesn't work as well - fails with cast error:

Cannot cast object '{"name":"Help","checked":false,"mandatory":false,"globalItemId":56712,"statusId":"none","rank":6,"id":7,"dueDate":null,"isHeader":false,"priorityId":null,"assigneeIds":[],"version":"5.0","linkedIssueKey":null}' with class 'java.lang.String' to class 'java.util.Collection'
at 0e54872ceb9b5a6e59e4cdcbcb9a102e.run(0e54872ceb9b5a6e59e4cdcbcb9a102e.groovy:8)

I went through the Checklist documentation https://okapya.atlassian.net/wiki/spaces/CHKDOC5/pages/3236659321/Getting+started+with+ScriptRunner and didn't find solutions to manage behavior of the Checklist on Create/Edit screen.

If you have good examples or documentation for my cases, please share.

Thanks in advance.


Checked in 2 different envs:

First instance:

Jira: v9.4.9

ScriptRunner: 8.9.0

Checklist: 6.2.4

Second instance:

Jira: v8.20.13

ScriptRunner: 8.1.0

Checklist: 6.2.4

3 answers

3 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 22, 2023 • edited

Hi @Alfira Merinova

I have gone through your description, and I have to say, unfortunately, Okapya Checklist is not currently supported by ScriptRunner's Behaviour. Hence, you are getting the current result.

However, a new feature request for this has been created. For your reference, the change request key is SRJIRA-2768.   

This feature may be added in future releases.

Also, the current documentation on ScriptRunner provided by Okapya does not apply to ScriptRunner's Behaviour. It is meant for Listeners / Post-Functions / Scripted Fields. Let me know if you want to try something using one of these, and I will try to provide an example. 

Another alternative I can suggest is to use the Standard Checklist provided by Jira. I can provide some examples using the Behaviour with the Standard Checklist.

Thank you and Kind regards,

Ram

Hi @Ram Kumar Aravindakshan _Adaptavist_ ,

Thank you for the clarifications.

 

Another alternative I can suggest is to use the Standard Checklist provided by Jira. I can provide some examples using the Behaviour with the Standard Checklist.

Yes, please, that would be very helpful. Could you please share these examples? I can replace Okapya Checklist with Standard Checklist, and need to implement behavior for these requests:

  1. Set several Checklist options "checked" based on the other custom field value on Create/Edit Screen.
  2. Another request is to make all options in Checklist read-only except one particular option on Create/Edit screen.
Like Josh likes this
2 votes
Maxime Lefebvre _Okapya_
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.
Sep 22, 2023

Hi Alfira,

Like Ram said, ScriptRunner Behaviours don't currently work with Checklist for Jira.

We have been working in collaboration with Adaptavist to eventually make it work. I will link your community post within our system and we will contact you in this post if/when we release an update that supports Behaviours.

Have a nice day!
Maxime

Hi @Maxime Lefebvre _Okapya_ , Thank you for letting me know. Yes, please, keep me informed.

0 votes
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 22, 2023

@Ram Kumar Aravindakshan _Adaptavist_  This is for you expert. :)

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.
Sep 22, 2023

Actually, I believe this is for @Maxime Lefebvre _Okapya_ or @Pascal Perreault _Okapya_ ;)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events