Scripted JQL function to check issuetype1.fixversion = issuetype2.fixversion

I have a requirement from the client where we need to compare fix version for 2 different types of issuetype.

Eg: Bug.fixversion > Task.fixversion. 

Can this be done using scripted jql function? If yes how can we accommodate more than one fix versions which are selected for the issue type.

3 answers

This widget could not be displayed.

So there is a relationship between PBI and SAR, perhaps through an issue link? At its simplest, this just involves querying for PBIs, finding their linked SAR, and comparing the two fields.

If there are multiple fix versions, you should find out what the client actually wants to happen. I would work out all the cases and permutations before you start implementing.

Also think how to compare two versions... do you want to compare by sequence, by release date, or using semantic versioning rules? Anyway, it's all perfectly doable.

Thank you Jamie. PBI and SAR are linked together using the structure. The comparison between all the fix versions for this issue types should happen through release date. Can you please help me in writing scripted jql query for this?How should the query be?

Hi Jamie Request your help ..

You want me to write it for you? That's not going to happen. Just make a start and ask specific questions when you get stuck.

no not write. among the list of issue functions which you have written. which is the closest one where i can try? because i tried it for the Query for PBI.SomeDateField > SAR.SomeDateField . But for the first one since there are more than 1 fix version per issue i am not sure how to compare the complete fix version list with the other

Hi Jamie.. I have wriiten the script by referring your code on date compare. class GetIssues extends AbstractScriptedJqlFunction { def String subquery String releaseDate private def String dateParams private def op @Override MessageSet validate(User user, FunctionOperand operand, TerminalClause terminalClause) { def messageSet = new NumberOfArgumentsValidator(1, 1, getI18n()).validate(operand) //eg deadline>fixversion def dateStr = operand.args[0] messageSet.addMessageSet validateDateComparison(dateStr) if (messageSet.hasAnyErrors()) { messageSet.addErrorMessage("Use comparison like > or <") } op = dateParams } MessageSet validateDateComparison(String dateStringOperator) { def messageSet = new MessageSetImpl() try { dateParams = dateCompareParser(dateStringOperator) } catch (Exception e) { messageSet.addErrorMessage(e.message) } messageSet } public String dateCompareParser(String param) { if (! (param =~ /[<>]/)) { throw new Exception("The comparison must contain a either > or < .") } op = param } /** * Implement this method for using datatype = IssueFunction * Delete it otherwise * @param queryCreationContext * @param operand * @param terminalClause * @return lucene query */ Query getQuery(QueryCreationContext queryCreationContext, FunctionOperand operand, TerminalClause terminalClause) { validate(queryCreationContext.user, operand, terminalClause) def booleanQuery = new BooleanQuery() def versionManager = ComponentAccessor.getVersionManager() def versions = versionManager.getAllVersions() def customFieldManager = ComponentAccessor.getCustomFieldManager() CustomField deadlineCustomField = customFieldManager.getCustomFieldObjectByName("Deadline") def match Set issueIds = new HashSet() for(Version v in versions) { releaseDate =v.getReleaseDate() if(op==">") { match = deadlineCustomField>releaseDate } else if(op=="<") { match = deadlineCustomField<releaseDate } if(match) { } } } } i need to write a issue function like dateCompare(Deadline > FixVersionReleaseDate) This query is fixed and wont change. So i am just getting the operator either > or <. Then i get release date for all versions in jira & all deadline and compare these two date fields and fetch only those issues which match the criteria. I have written down something but i dont know how to fetch the issues. Is this logic somewhat correct.

Reasonably, other than you're not returning anything. I think you should be able to use linkedIssuesOf to get all PBIs or whatever, and then do the version comparison...

Thanks Jamie for replying. I didnt get "use linkedIssuesOf" . Did you mean to say that instead of using the above script use linkedIssuesOf or use this along with the script above.? Also these issues are linked to another type of issue using "structure" can this jql function work for this? Because these are the set for the available links Available links are: [Defect on, Defects infused, is Epic of, has Epic, FF-depends on, is FF-depended by, FS-depends on, is FS-depended by, Link To, Link From, SF-depends on, is SF-depended by, SS-depends on, is SS-depended by] . Where does Structure fit in here

Also Jamie how can i modify the existing code which i have pasted above to pass the issue ids which satisfy the criteria. I mean how to make the function return the matching issues? if(match) { //need to flush out issue ids }

This widget could not be displayed.

I'm sure you can but what is your requirement exactly. Can you give an example? It's not at all clear.

This widget could not be displayed.

Sorry there was a typo in the above question just edited it. We have 2 types of issues in our system PBI and SAR. SAR is like topmost and then we have PBI . Each have their own set of fix issues. So the client wants a query by which they can compare the fix versions for this issue. This is purely for their management related activity. I have actually no idea about the exact requirement as of now. So they have given 2 such requirements: 1)Query for PBI fixVersion > SAR fixVersion 2)Query for PBI.SomeDateField > SAR.SomeDateField

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 yesterday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

55 views 1 0
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