Scriptrunner behaviour - Prevent Fix Version updates during multiple statuses

Shannon Bennett
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 23, 2020

I have tried a few methods, but I'm unable to prevent the Fix Version/s field from being edited in about 4 statuses.  I've created a Behaviour and tried the following conditions (at different times), but neither are preventing edits to the Fix Version/s field.

When : Workflow Step <status 1>
            Workflow Step <status 2>
            Workflow Step <status 3>
            Workflow Step <status 4>

 &

Except: Workflow Step <status 5>
            Workflow Step <status 6>
            Workflow Step <status 7>
            Workflow Step <status 8>
            Workflow Step <status 9>
            Workflow Step <status 10>

 

The Behaviour is mapped to All Issue Types & a few projects.  The workflow steps would also span multiple workflows.

I have another Behaviour preventing a custom field from being edited by project role, not status.  I tried disabling that to see if they were conflicting with each other, but no luck.

3 answers

1 vote
Leo
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 1, 2021

Hi @Shannon Bennett,

I have tested below code in my sandbox by adding it as server-side script for fix versions field in behaviour 

def fVersions = getFieldById("fixVersions")
def status = underlyingIssue?.getStatus().name
if(status == "To Do"){
fVersions.setReadOnly(true)
}else{
fVersions.setReadOnly(false)
}  

Hope this helps 

 

BR,

Leo 

0 votes
Radek Dostál
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.
December 25, 2020

Behaviours will not work on the "View screen", rather if a field is "affected" by a behaviour and a user tries to edit it, it will direct them to the Edit screen instead where the Behaviour should work.

 

Could you show us the behaviour implementation -- the settings and conditions?

Could we eliminate this being a bug by setting the fixVersion field read-only at all times, in some sample project? Just to see if it will work regardless of the status.

0 votes
Alexandre de Sousa December 23, 2020

Hi @Shannon Bennett ,

 

See if these two links below could help you to achieve your goal:

https://library.adaptavist.com/entity/set-behaviour-read-only 

https://scriptrunner.adaptavist.com/5.0.2/jira/recipes/workflow/get-workflow-vars.html 

Try to use if-else statements in your Behaviour to set the setReadOnly() method as true or false and determine which status the field can or cannot be edited.

 

I hope this can help you.

 

BR,

Alexandre de Sousa.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.10.0
TAGS
AUG Leaders

Atlassian Community Events