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

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,559,695
Community Members
 
Community Events
185
Community Groups

Is there anyway in ScriptRunner to limit a behavior to the Jira Edit function only?

I want a user to be able to enter information into a 'business value' field but not edit that field after the initial entry.  

I have set up a behavior that  restricts entry to the field except when 'current user is in group a'.  However, I want any user in the project who enters a jira issue of that type to be able to input the initial data into the field.  I just do not want them to be able to edit it after initial save.

1 answer

1 accepted

0 votes
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 08, 2019

You can use getActionName()

if(getActionName() == 'Create' || userIsInGroup){
field.setReadOnly(false)
} else {
field.setReadOnly(true)
}

Thank you for this.  I am still struggling.  I am not technical.  Below is the xml that was created by the Scriptrunner addon when I set this up to restrict access to the field except when current users is a particular group.  I want it to do this but only restrict when the function is edit.

I am not sure how to get that statement above into the xml that the interface created as it is not in what looks to be an xml format.

<config name="Play with edit restrict" description="figure out how to restrict field to edit only but the RTE group" use-validator-plugin="false" guideWorkflow="null">
<field id="customfield_15907" validator-script="" validator-class="" validator-method="" readonly="true" required="false" hidden="false" validator="server">
<except group="1-RTE"/>
</field>
</config>

Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 11, 2019

Inf the "fields" configuration for the behavior, select the correct workflow for your project.

Then, against your custom field that you want to be read-only, click the "add new condition" and select Except and Workflow Action = Create (1).

What this will do is make the field read-only except when the user is in 1-RTE or when the screen is the create screen. 

If you need more complex conditional rules, then you would need to click the "Add server-side script" and write some script code that can control the behavior rules. But I think with your current example, with just 2 "Except" condition, you can manage without any code.

Like Melissa Thornton likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events