Allow Current Reporter to edit Reporter field on a specific Status only in Jira data center?
Asked by Digvijay Singh Gehlot:

Hi Community,

I want to allow the currentUser as Reporter to edit the Reporter field on a specific Status (like "Open") only if he is NOT a part of particular Groups (like Group A, Group B, Group C).

If the currentUser as Reporter is part of above Groups, then he is allowed to edit Reporter field on any status of the workflow.

How can I configure this by using Scriptrunner, JMWE app, JSU, Jira automation or Validation/ Conditions/ Post-functions?

Please guide further and let me know if you need any additional details.

Thanks


Answers:
author: Ram Kumar Aravindakshan _Adaptavist_
body: Hi [@Digvijay Singh Gehlot](/t5/user/viewprofilepage/user-id/5431110)

For your requirement, it would be best to use ScriptRunner's Behaviour Initialiser.

Below is a sample working code for your reference:-  

```
import com.adaptavist.hapi.jira.groups.Groups
import com.adaptavist.hapi.jira.users.Users
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours behaviours
def loggedInUser = Users.loggedInUser
def devGroup = Groups.getByName('Developers')
def reporter = getFieldById('reporter')


if (underlyingIssue) {
    if (underlyingIssue.status.name == 'In Progress' && devGroup.contains(loggedInUser)) {
        reporter.readOnly = false
    } else {
        reporter.readOnly = true
    }
}
```

Please note that the sample working code above is not 100% exact to your environment. Hence, you must make the required modifications.

Below is a screenshot of the Behaviour configuration:-

![behaviour_config.png](https://community.atlassian.com/t5/image/serverpage/image-id/341673i5DBB8C35AA7CECEC/image-size/large?v=v2&px=999 "behaviour_config.png")

Note: For the Behaviour to work, if the user whom you have added to the Group is not a Jira Admin, you must at least grant the user Project Admin permission else the user will not be able to edit the Reporter field once the Issue has been created and the Behaviour cannot be triggered.

I hope this helps to solve your question. :-)  

Thank you and Kind regards,  
Ram

comments: author: Digvijay Singh Gehlot
body: Hi [@Ram Kumar Aravindakshan _Adaptavist_](/t5/user/viewprofilepage/user-id/2988015)

As always, thank you so much for providing a detailed explanation on how to use scriptrunner at its best to solve my specific requirements.

I clearly understood the workflow and will implement the same at my end, and let you know if I need any additional refinements.

Best,

Digvijay


author: Tomasz Kowalczyk
body: For open status you can use workflow properties like jira.permission.modifyreporter.user but i'm aware of that it require you to do that property for a group not a negation of a list of groups. So you can set that members of three groups can modify reporter. More you can read about here <https://support.atlassian.com/jira-cloud-administration/docs/use-workflow-properties/>

or here:   
<https://confluence.atlassian.com/adminjiraserver/workflow-properties-938847526.html>  

comments: author: Digvijay Singh Gehlot
body: Hi [@Tomasz Kowalczyk](/t5/user/viewprofilepage/user-id/3784490)

Thank you for your message.

I gone through the shared links but not able to find on how to pass this Property Key: jira.permission.modifyreporter.group for multiple groups on a particular status.

And I am also not able to find the Group value to enter in Property Value field in Jira-datacenter

Can you guide me further what will be the correct property key for multiple groups and how to find the Group id/value to set them in Property Value on a specific status in Jira data-center?


author: Tomasz Kowalczyk
body: well,

try like that:  
first property

property:jira.permission.modifyreporter.group.1 value: \<group name\>

second property  
property:jira.permission.modifyreporter.group.2 value:\<second group name\>  

property value should be the name of a group


author: Digvijay Singh Gehlot
body: Hi [@Tomasz Kowalczyk](/t5/user/viewprofilepage/user-id/3784490)

Thanks again.

I am able to set the Property Key and Value as you guided.

I observed that:

* After setting the property: jira.permission.modifyreporter.group.1 and the currentUser is NOT a part of Group 1 then the Reporter field is NOT visible on the Edit Issue screen.

I would like to ask, is there a possibility to set the Reporter field as ReadOnly for the currentUser as Reporter (who is NOT part of Group 1) on a particular status when he opens the Edit Issue screen?

For example:

* When currentUser as Reporter (NOT a part of Group 1), opens the Edit Screen on a specific status, he is able to see the Reporter field as ReadOnly, hence he is not able to edit it.
* When user from Group 1, opens the Edit screen on a same status, he can edit the Reporter field.

Looking forward to hearing from you soon.


author: Tomasz Kowalczyk
body: No, with properties you're able to set who CAN modify reporter not otherwise as i mentioned in my first answer. But you can achieve this by moderating groups. Why don't you try to achieve this by moderating also group membership. You can create gruop that gather all users/groups that CAN modify reporter and than just add that group to workflow properties


Tags: automation

condition

current-user

data-center

jira-data-center

jmwe-app

jsu

post-function

reporter

scriptrunner

user-group

validation