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

This widget could not be displayed.

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.

This widget could not be displayed.

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

This widget could not be displayed.

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; } } 

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

129 views 16 7
Join discussion

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