How to validate Linked issue on transition screen

salman_kagzi May 8, 2014

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

0 votes
Answer accepted
Florin Manaila
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 Leaders.
May 8, 2014

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

Florin Manaila
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 Leaders.
May 8, 2014

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.

salman_kagzi May 8, 2014

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...

Florin Manaila
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 Leaders.
May 8, 2014

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.

0 votes
Peter Van de Voorde
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 8, 2014

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

salman_kagzi May 8, 2014

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 :)

Like # people like this
0 votes
salman_kagzi May 8, 2014

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

0 votes
Alexandru_Iacob
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 Leaders.
May 8, 2014

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events