Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

hiding custom field based on user group--Date field

Hi Team,

We have a custom field(date field) which needs to be hide by a specific group of uses.
We have tried it in  Script runner Behaviours but no action is performed.
Kindly help us to solve this using Script or Conditions using Scriptrunner Behaviours.

Please find the below script that we used to perform the action:

import com.atlassian.jira.component.ComponentAccessor

def groupManager = ComponentAccessor.getGroupManager()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def customField = getFieldById("customfield_12305")
def remoteUsersRoles = ComponentAccessor.getGroupManager().isUserInGroup(currentUser, "ut-state")
if (remoteUsersRoles) {
customField.setHidden(true)
}

Thanks in Advance

BR,
Revathy Madhavan

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jul 12, 2022

There is nothing functionally wrong with your code.

Where did you put it?

Showing/Hiding a field based on the current user is probably best done from the Initialiser.

Here is a simplified version:

import com.atlassian.jira.component.ComponentAccessor

def groupManager = ComponentAccessor.groupManager
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def groupName = 'ut-state'
def isInGroup = groupmanager.isUserInGroup(currentUser, groupName)
getFieldById("customfield_12305").setHidden(isInGroup)

Hi Peter,

As you suggested i have put the code in Initializer but still it is viewable & editable for the mentioned group users.
Kindly help us to fix this

Behaviour--Hiding field--UT Group.PNG

Regards,
Revathy Madhavan

Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jul 13, 2022

Please read-up on the behaviour limitations:

https://docs.adaptavist.com/sr4js/latest/features/behaviours/behaviour-limitations#id-.BehaviourLimitationsv6.19.0-Screens

You can't hide a field from the view screen.

And while the field may appear editable, usually, if behaviour is working correctly, when you click on the in-line edit button, it will force the full edit screen to open where the behavior will enforce the field to be hidden.

Hiding fields with behaviours should only be done for the sake of convenience, it will not ensure any sort of privacy or confidentiality. It's quite easy to query this information either in a regular issue navigator or by accessing the REST api.

TAGS
AUG Leaders

Atlassian Community Events