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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Need help on making issue link mandatory on create and edit (if there is not links present already)

Hi

I am very new to scripting. I have a requirement to set Issue linking mandatory while creating an issue.
I have to set Linked issues to "is part of" (inward link) and also in issues field, it should only show tickets from that same project only.

However to make it mandatory I used behavior and added below code.

getFieldById("issuelinks-linktype").setFormValue("is part of").setReadOnly(true)
getFieldById('issuelinks-issues').setReadOnly(false)


for some part, it is working fine. It is making issue linking mandatory while creating the issue also link type is set to "Is part of"

But the main problem is whenever I am trying to edit one issue, at that time even if there is already an existing link it is again asking to fill in the linking issue-issue filed.

and is it possible to show issue from the same project only in that issue filed?

any help would be highly appreciable. 

2 answers

2 accepted

2 votes
Answer accepted

Hi @Durga prasad panda 

Start with this piece of code.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink

def links = getFieldById('issuelinks')
def linksValue = links.getValue()
def linkType = getFieldById("issuelinks-linktype")
def linkTypeValue = linkType.getValue()
def linkField = getFieldById('issuelinks-issues')
def linkFieldValue = linkField.getValue()

def existingLinks = ComponentAccessor.getIssueLinkManager().getInwardLinks(underlyingIssue?.getId())

if (existingLinks?.size() == 0 && linkTypeValue == "is part of") {

links.setRequired(true)

} else {

links.setRequired(false)

}

It should make the link field required on creation and on edit later when there are no existing links but the code will not work when user clicks on the link option under the more or in the link section, for that you will have to write your own JavaScript.

Ravi

Hi @Ravi Sagar _Adaptavist_ 

Is there way to restrict which issues from which project/same project can be selected only in the linked issue?

by the way thanks the above solution worked like charm

@Ravi Sagar _Adaptavist_ 

I added the same beahviour code for workflow condition - ( create action)  and mapped the corresponding project. it is not making the field "Issue" as mandatory.

I am able to make the Linked issue required field but the associated field "Issue" (with link types) not working on create transition. We want to force the user to enter value (actually link some issue to the issue being created) for linked issues field upon creation.

Also, Tried the following link . but no Luck - https://community.atlassian.com/t5/Jira-questions/Make-quot-Issue-Link-quot-a-required-field-is-not-being-enforced/qaq-p/310724

Please advise.

0 votes
Answer accepted

Use the behaviour's Guide Workflow
Add a new condition of workflow action of Create (1) for the field

Thanks @Amit Girme for the reply. It is also working but the only thing is it is not checking for the links in the edit field. :)

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you