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

scriptrunner behaviour: read-only field improperly switches back to read-write

Brent Webster
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.
October 7, 2015

I've switched to using ScriptRunner Behaviour to make

  • several fields read-only except if the current user has a 'Manager' project role or it is occurring during the 'Create' transition
    All these fields are also marked 'Required'.
  • one field: "Target Release" is read-only except if the current user has a 'Manager' project role
  • one field: "Churn" is always read-only and only updated by a post-function groovy script when resolving

When creating a new issue, the transition menu screen pops up and I begin entering data.  The "Target Release" and "Churn" fields are greyed out and not editable – great.  I don't complete the entry of required fields and select the "Create" button.  I get the "XXXX is required" error messages under all the required fields that aren't filled but now the "Target Release" and "Churn" fields aren't greyed out and are editable – not great.

The following is the debug log messages generated when the screen first pops up:

2015-10-07 16:52:54,003 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] must be in role: 10200
2015-10-07 16:52:54,004 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] user swguy1(swguy1) must be in role Managers
2015-10-07 16:52:54,004 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] return true for initial action
2015-10-07 16:52:54,004 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] must be in role: 10200
2015-10-07 16:52:54,004 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] user swguy1(swguy1) must be in role Managers
2015-10-07 16:52:54,004 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] return true for initial action
2015-10-07 16:52:54,004 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] must be in role: 10200
2015-10-07 16:52:54,004 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] user swguy1(swguy1) must be in role Managers
2015-10-07 16:52:54,004 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] must be in role: 10200
2015-10-07 16:52:54,004 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] user swguy1(swguy1) must be in role Managers
2015-10-07 16:52:54,004 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] return true for initial action
2015-10-07 16:52:54,004 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] must be in role: 10200
2015-10-07 16:52:54,004 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] user swguy1(swguy1) must be in role Managers
2015-10-07 16:52:54,004 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] return true for initial action
2015-10-07 16:52:54,004 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] must be in role: 10200
2015-10-07 16:52:54,004 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] user swguy1(swguy1) must be in role Managers
2015-10-07 16:52:54,005 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] return true for initial action
2015-10-07 16:52:54,005 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] must be in role: 10200
2015-10-07 16:52:54,005 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] user swguy1(swguy1) must be in role Managers
2015-10-07 16:52:54,005 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] return true for initial action
2015-10-07 16:52:54,005 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] must be in role: 10200
2015-10-07 16:52:54,005 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] user swguy1(swguy1) must be in role Managers
2015-10-07 16:52:54,005 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] return true for initial action
2015-10-07 16:52:54,005 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] return true for initial action
2015-10-07 16:52:54,005 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] must be in role: 10200
2015-10-07 16:52:54,005 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] user swguy1(swguy1) must be in role Managers
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] must be in role: 10200
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] user swguy1(swguy1) must be in role Managers
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] return true for initial action
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] must be in role: 10200
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] user swguy1(swguy1) must be in role Managers
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] return true for initial action
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] must be in role: 10200
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] user swguy1(swguy1) must be in role Managers
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] must be in role: 10200
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] user swguy1(swguy1) must be in role Managers
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] return true for initial action
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] must be in role: 10200
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] user swguy1(swguy1) must be in role Managers
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] return true for initial action
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] must be in role: 10200
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] user swguy1(swguy1) must be in role Managers
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] return true for initial action
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] must be in role: 10200
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] user swguy1(swguy1) must be in role Managers
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] return true for initial action
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] must be in role: 10200
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] user swguy1(swguy1) must be in role Managers
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] return true for initial action
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] return true for initial action
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] must be in role: 10200
2015-10-07 16:52:54,009 http-bio-8080-exec-17 DEBUG swguy1 1012x12747x1 leah5j 192.168.109.116 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validatorsByPid.json [onresolve.jira.groovy.Behaviour] user swguy1(swguy1) must be in role Managers

And the following is the xml output from Behaviour's Edit panel:

<config use-validator-plugin="false" name="Reporter/Validator Only Modify Behaviour" description="Reporter/Validator Only Modify Behaviour" guideWorkflow="Coriant One MR Workflow">
  <init id="__init__" required="null" readonly="null" hidden="null" validator="server" validator-class="/opt/atlassian/Jira-Coriant/scripting/fieldsBehavourInitializerFunction.groovy" validator-script="" validator-method="coriantInitsubStatusField"/>
  <field id="customfield_10302" required="null" readonly="true" hidden="null"/>
  <field id="priority" required="true" readonly="true" hidden="null">
    <except role="10200"/>
    <except action="1"/>
  </field>
  <field id="customfield_10202" required="true" readonly="true" hidden="null">
    <except role="10200"/>
    <except action="1"/>
  </field>
  <field id="customfield_10210" required="null" readonly="true" hidden="null">
    <except role="10200"/>
  </field>
  <field id="issuetype" required="true" readonly="true" hidden="null">
    <except role="10200"/>
    <except action="1"/>
  </field>
  <field id="customfield_10205" required="true" readonly="true" hidden="null">
    <except role="10200"/>
    <except action="1"/>
  </field>
  <field id="components" required="true" readonly="true" hidden="null">
    <except role="10200"/>
    <except action="1"/>
  </field>
  <field id="customfield_10401" required="null" readonly="true" hidden="null">
    <except role="10200"/>
    <except action="1"/>
  </field>
  <field id="customfield_10304" required="null" readonly="true" hidden="null">
    <except role="10200"/>
    <except action="1"/>
  </field>
  <field id="customfield_10402" required="null" readonly="true" hidden="null">
    <except role="10200"/>
    <when action="1"/>
  </field>
</config>

7 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
JamieA
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.
October 13, 2015

I think this is a regression: https://jamieechlin.atlassian.net/browse/GRV-819 . In that issue there is a possible workaround.

Alejandro Reyes October 10, 2018

In the latest version of scriptrunner you can add that the fields return to readonly selecting that the behaviour launches on the workflow action Create(1). It launches the error and returns it to Read Only ^^cap.PNG

0 votes
Brent Webster October 13, 2015

Jamie, any chance you can comment on the possibility for a solution. If this doesn't work, I'll have to revert to a validator script checking the values at the back end rather than having Behavior locking the fields at the front end which would be my preferred solution. Behavior is a better and prettier solution.

0 votes
Brent Webster
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.
October 8, 2015

Finally, I deleted all field behaviors and the field initializer except for the one read-only field: "Target Release" but it still became read-write.

0 votes
Brent Webster
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.
October 8, 2015

Upgraded to Jira 6.4.11 and the problem still persists.

0 votes
Brent Webster
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.
October 8, 2015

I just updated Scriptrunner to 3.1.4 and it still shows the behaviour (no pun intented ;-) )

0 votes
Brent Webster
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.
October 8, 2015

Sorry about that. Jira 6.4 and Scriptrunner 3.0.11

0 votes
JamieA
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.
October 7, 2015

Please provide jira and plugin version

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events