Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to restrict change custom fields from specific values? Scriptrunner

Greetings!

I have a next case:

I m  trying to restrict changing customfield (type: Deviniti [Dynamic Forms] - Dynamic Select)

It has 3 values: error, customization, changeApp. I want to forbid changing values from error to changeApp and customization to changeApp. 

I suppose it can be done by scripts (listeners or behaviours) but i have no relevant expirience of writing dificult scripts. If someone can help or have workaround, pls help.

image-2021-06-10-13-35-16-512.png

1 answer

1 accepted

0 votes
Answer accepted

Unfortunately, from Deviniti documentation, Dynamic Forms for Jira is not compatible with ScriptRunner's Behaviour, you can log your request to ScriptRunner support portal. The more requests, the likely the Product Manager will work on this matter.

Anyway, for other users, Behaviour is the best choice in this use case. If you are using ScriptRunner 6.26 or above, setFieldOptions() is made easier.

So, you can attach following snippet to Initialiser:

def selectField = getFieldByName("Your Select Field Name")

if (underlyingIssue && selectField.getValue()) {
if (selectField.getValue() == "error") {
selectField.setFieldOptions(["error", "customization"])
} else if (selectField.getValue() == "customization"){
selectField.setFieldOptions(["error", "customization"])
}
}

First if statement tests whether you are editing an existing issue with the field is set before. The rest should pretty much self-explanatory.

ah, the snippet can be actually further simplified:

def selectField = getFieldByName("Your Select Field Name")

if (underlyingIssue && selectField.getValue()) {
if (selectField.getValue() != "changeApp") {
selectField.setFieldOptions(["error", "customization"])
}
}  

I just tested it, awesome! Thank you so much!

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

Introducing External Collaboration for Confluence

We’re excited to introduce external collaboration for Confluence, now available in early access. It is available to preview for Confluence Cloud Premium and Enterprise customers. (If you're not on ...

186 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you