Forums

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

How to hide fields from Inline edits through Script Runner Behaviour Template

Jyoti Kumari
Contributor
April 3, 2023

Hello Everyone,

I want to hide fields for inline edit through Script Runner Behaviour Template,Kindly guide me how to achieve this.I am able to hide it, when we are clicking on Edit button.

For Example:-

I want to hide priority from editing.

2 answers

Suggest an answer

Log in or Sign up to answer
3 votes
JamieA
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 Champions.
September 25, 2017

Here is sample code for a Move Issue event listener:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.UpdateIssueRequest

// optionally, check from/to project and conditionally execute...

def issueManager = ComponentAccessor.getComponent(IssueManager)
def customFieldManager = ComponentAccessor.getCustomFieldManager()

def sprintCf = customFieldManager.getCustomFieldObjectByName("Sprint")
def user = event.user

def issue = issueManager.getIssueObject(event.issue.id)
issue.setCustomFieldValue(sprintCf, null)
def updateIssueRequest = UpdateIssueRequest.builder().
eventDispatchOption(EventDispatchOption.DO_NOT_DISPATCH).
historyMetadata(null)

issueManager.updateIssue(event.user, issue, updateIssueRequest.build())
Dominik
September 26, 2017

I have created a CustomListener and inserted the sample code. It worked. :-) There is also a possibility when cloning issues

JamieA
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 Champions.
September 26, 2017

Yes, it worked, because I tested it ;-) An upvote would be nice!

Dominik
September 26, 2017

Which event needs to be trapped so that it can work when cloning? Thank yoimage.png

JamieA
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 Champions.
September 26, 2017

That's a more complicated question... see https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-detect-if-an-issue-is-a-clone-in-a-listener-at/qaq-p/562675. If you are on jira 7.5 you could do it on IssueLinkCreated and check if it's the cloners link I guess.

1 vote
Nic Brough -Adaptavist-
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 Champions.
September 21, 2017

Moving an issue tries to retain as much of the issue as the target project allows for, and as Sprint is a global field, it's not going to clear it.

You are right you can do it with ScriptRunner - a listener could be scripted to catch "issue moved", check you want to lose the sprint and clear it (and other fields) by setting them to "null".

TAGS
AUG Leaders

Atlassian Community Events