Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scriptrunner Behaviours not completely and consistently for all users on all creation screens

Melanie Pasztor
Contributor
January 17, 2020

Hello!

I created a scriptrunner behaviour with some custom fields, where selecting a specific select option in Field A reveals and makes mandatory Field B and C. The script runs and works. 

The issue is that it does not work for all screens for all users. In Jira server, there are at least two creation screens. The one that appears when you click on Create from a project, issue or agile board page where creation screen pops up. The other is the Create issue page you get directed to after clicking Create button, or when you right-click and Open Link in New Tab / Window. 

Behaviour works for all users I tested with for the latter, but for the create popup window, Field B and C do not visually appear for some users after selecting the specific select option of Field A, yet setting them to mandatory part works. 

I am not sure if this is a bug jira and scriptrunner behaviour, or permission thing. I just know it works for me the jira/system admin and all of the project users, yet does not for the project admin. 

The script does not even have any project role or permissions check, so should be working for everyone that has permission to the project that the script is mapped to. 

Any help or something I can check would be appreciated. 

Currently Jira 7.13, with Scriptrunner 5.4.45.

 

2 answers

1 accepted

0 votes
Answer accepted
PD Sheehan
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.
January 17, 2020

Have you looked to see if users have customized their create screen? 2020-01-17 12_08_22.pngIf they have, then you will know how to replicate as an admin and tweak your script accordingly.

I know that behavior can't override the user's preference and show the field. And I'm not sure if there is a way to detect that a field is hidden like that. I tried a while ago isHidden() but this only reports the status of setHidden(true/false). Maybe this will require a feature request to Adaptavist.

At the least, it would be nice to detect the missing field and provide feedback to the user that they must un-hide it.

Melanie Pasztor
Contributor
January 17, 2020

Ahhh, completely forgot about that. They had Custom selected with no checkmark for the Field B and C. Thank you! 

0 votes
Leo
Community Champion
January 17, 2020

Hi @Melanie Pasztor,

as per my knowledge Scriptrunner's behaviour won't hide any fields unless below code is being used: field.setHidden(true)

Have you checked that those fields are not visible in screen by default for them? if so they have to check "Configure fields" option in top right corner of create screen and select those fields

 

BR,

Leo

Melanie Pasztor
Contributor
January 17, 2020

They are not visible until they are selected. I know of the error you are referring to, as I seen it in the process of troubleshooting the script before. It presently works as intended. Just does not work on one create screen for one user (while working on the other create screen for them), while it works as intended with my and other user profiles. 

Here is the server side script for the selectfield:

def impactField = getFieldById("customfield_15890")
def effortField = getFieldById("customfield_15891")
def severityField = getFieldById(getFieldChanged())

def selectedOption = severityField.getValue() as String
def isImprovementSelected = selectedOption == "Improvement"

//severityField.setHelpText("selectedOption=$selectedOption isImprovementSelected=$isImprovementSelected")

impactField.setHidden(! isImprovementSelected)
impactField.setRequired(isImprovementSelected)
effortField.setHidden(! isImprovementSelected)
//effortField.setRequired(isImprovementSelected)
Leo
Community Champion
January 17, 2020

script looks ok for me, but not sure. maybe someone can help you out 

Suggest an answer

Log in or Sign up to answer