How to validate Linked issue on transition screen

I have added Link Issues field to my Create and some of the Transition screens. I want to control on the Type of Issues which can be linked to a specific Issue Type. After couple of attempts I resorted to using SIL Validatiors in Create & Workflow Transitions. But I never get the list of issues which user is trying to Link when using linkedIssues API.

My guess here is, since the validators are called before the changes are saved, these API wont work when trying to fetch data which is at that instance transient. i.e. still pending to be written.

So if this wont work then, Is there something else which can be used in its place?

4 answers

1 accepted

Hi Salman,

You are completely right about the transient values.

As it stands now, the only way I can think of that would solve your problem is to use a live fields configuration that would call lfExecuteJS() to run some javascript code (this is not going to be easy) that would prevent the user from selecting the wrong issue type in the transition screen.

HTH

However, you can just remove the wrong issues in a post-function placed at the end of the post-functions chain, but i'm not sure "disappearing" issue links is acceptable practice.

Disappearing links is a no go. The JavaScript one is something I will look into. But I cant really get around my head how will I get the issuetype of the selected issues there. Thinking...

At this point I think your best option is to write your own addon that will provide the validator. It's easier than the javascript alternative.

Check out https://developer.atlassian.com/display/JIRADEV/Creating+Workflow+Extensions

It's complete with full example plugin source code and everything.

Hi Salman,

Can you please attach the SIL script that you are using as validator in Create & Workflow transitions? Plese let us know also what Jira and JJupin versions are you using.

Thanks,

Alex

I am using Jira 6.1.2 and JJupin 2.6.8

if (issueType == "Feature Task") {
    string [] linkedIssues = linkedIssues(key, "Contributes", 1);
    string errorMessage;

    if (arraySize(linkedIssues) > 1) {
        errorMessage = "Feature task can be associated to only 1 New Feature item.";
} else if (arraySize(linkedIssues) == 1) { for (string likedIssue in linkedIssues) { if (%linkedIssue%.issueType != "New Feature") { errorMessage = "Only a new feature can be set as Contributes to."; } } } if (length(errorMessage) > 0) { return false, errorMessage; } } 

Wouldn't it be easier to simply train your users instead of trying to force this on them?

Why aren't they allowed to link to certain issue types?

Best regards,

Peter

If it was that easy, there would have been no need for Validation & Condittions in Jira.

These restrictions are to enfore a workflow around specific type of issues based on the way things are done here. The end result is the reports as we need them :)

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published 3 hours ago in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

55 views 4 4
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you