Forums

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

Current user validation using Behaviours-plugin

Rathna
Contributor
June 13, 2018

Hi,

How would I achive the below using Adaptavist's Behaviours Plugin 

Scenario:

we have two single line text custom fields. I would like to know if there is anyway to enable/display these two fields to only to none other than one user in the instance.

I was also looking at Javascript options also from other answers, but our users use blockers to block scripts. So I was looking to enforce it from the server-side instead of the client-side.

Any assistance is greatly appreciated.

1 answer

0 votes
Mark Markov
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.
June 13, 2018

Hello @Rathna

Try code bellow, placed in behaviours mapped to your project, issuetypes and setted to fields you need.

import com.atlassian.jira.component.ComponentAccessor


def
user = ComponentAccessor.getUserManager().getUserByName("username")
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
if (currentUser != user){
//left one depends on your case
getFieldById(getFieldChanged()).setHidden(true) // to be hidden
getFieldById(getFieldChanged()).setReadOnly(true) //to be readonly
}

Suggest an answer

Log in or Sign up to answer