Forums

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

customField.setAllowInlineEdit(false) is not working in Behaviour

Dan27
Contributor
June 29, 2020

Hello,

 

I want to 'read only' field fixVersion in Jira.

In edit screen in is working okay, But in view screen it is not read only and users can edit it.

I tried to use this intialiser without success:

def customField = getFieldByName("Fix Version/s")
customField.setAllowInlineEdit(false)

 

What am I doing wrong?

Thank you,

Daniel

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Antoine Berry
Community Champion
October 22, 2021

Hi @Samar Elsayed ,

I have modified your snippet a bit, could you try this one : 

import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger
import org.apache.log4j.Level


def logg = Logger.getLogger("")
logg.setLevel(Level.DEBUG)

def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser

def groupsval = ComponentAccessor.groupManager.getGroupsForUser(user)
return groupsval

Antoine

Samar Elsayed
October 22, 2021

Hi @Antoine Berry ,

 

I have tried that already but it still gives me :

,

 

I have tried to use a custom template instead of group picker :

Capture.PNG

but it gives me the whole list when I use only 

return groupsval

 as below :

[confluence-administrators, agile team]

and when I use the for loop for the list, I get the first element only :

 

Capture.PNG

Like Antoine Berry likes this
Samar Elsayed
October 22, 2021

@Antoine Berry  do you know how can I get all the groups to appear as options not just one? 

Antoine Berry
Community Champion
October 25, 2021

Hi @Samar Elsayed ,

This is my configuration : image.png

Using my script above, this is the output on the view screen of an issue : image.png

As you can see this is working correctly. Please remember that a script field only calculates values, but does not provide a list of option (meaning that it will only be available on view screen).

If you want the user to select a group among the user groups, you would need to create a group picker, and update options with a behaviour script.

Samar Elsayed
October 25, 2021

@Antoine Berry thank you. can you please give me an example about how to do that in 

a behaviour ?

Like Antoine Berry likes this
Antoine Berry
Community Champion
October 27, 2021

Hi @Samar Elsayed ,

Actually using a group picker field, I think you could only auto-select the user's groups, but not restrict its values.

You could restrict the values of a regular select list, but this would mean having all the groups as options in the field configuration (= a lot of maintenance).

Alternatively you could throw an error if the group selected is not one of the current user's.

TAGS
AUG Leaders

Atlassian Community Events