The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
  • Community
  • Q&A
  • Jira
  • Questions
  • Trying to use a script to set a field readonly based on a linked issue type in a certain status

Trying to use a script to set a field readonly based on a linked issue type in a certain status

Omar Rashid
July 21, 2021

We are trying to prototype using a script to account for the following scenario:

If a story in the demo status is transitioned to the next status of 'Accepted', a transition screen is popped up which contains a field called 'Bug Management' which is a checkbox. We want to set this field to read only IF the story has a linked bug to it which is in the open status. Also need to show an error message on the screen, or under the screen when the field is set to read only due to matching the conditions

How can this be accomplished? Using behaviors or script listeners?

Started off with the following code which is not working:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueFieldConstants
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.status.Status
import com.atlassian.jira.issue.issuetype.IssueType
import com.atlassian.jira.config.ConstantsManager
import com.atlassian.jira.config.StatusManager

def Field = getFieldByName("Bug Management")
def StoryStatus = StatusManager.name == "Accepted"
//def LinkType = IssueLinkManager.any()

if (StoryStatus && LinkType == (true))

{Field.setReadOnly(true)}

Thanks & Regards!

0 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

DEPLOYMENT TYPE
SERVER
VERSION
8.8.1
TAGS
AUG Leaders

Atlassian Community Events