Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
  • Community
  • Q&A
  • Jira
  • Questions
  • Script runner: creating sub-tasks based on Version field (selections) - Don't create if already exis

New users have access to this product

Ivan Andrieiev
Contributor
August 4, 2022

What does it mean in the product settings in the administration panel "New users have access to this product", new users will not be able to choose a Jira product, if, for example, they were initially invited only to confluence?

access jira.png

1 answer

0 votes
Alexey Matveev
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 Champions.
March 26, 2018

How would you know if sub task exists or not?

Nic Brough -Adaptavist-
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 Champions.
March 27, 2018

You have to make assumptions based on your business logic.

For example (and this is a real one I wrote listeners for, although I've simplified)

  • Event: Team Tour Amsterdam
  • Event has a multi-user select field "attendees"
  • Listener creates sub-tasks like this:
    • Sub-task: Hotel for Eliza
    • Sub-task: Hotel for Nic
    • Sub-task: Hotel for Neil

If the issue is edited, the attendees field has Laura added.  So, my code has to go:

  • For each attendee (Eliza, Laura, Neil, Nic)
    • Check if there is already a subtask with summary "Hotel for <attendee>"
    • If not, then create a new one for the new person (The code will only create "Hotel for Laura" when she's added to the field)

In this case, the logic is quite simple, and the users know that if they edit a summary of a sub-task, they may end up with a duplicate.  We're not yet enforcing a stronger check in code, just monitoring it to see if it does become a problem.

I think @SidhR needs to look at his business logic, and work out how to answer the question "does this sub-task already exist" in that context.

SidhR
March 30, 2018

Thanks for the clarification Nic. This is what I have managed so far but still having hard time what to compare the Summary with? 

def reqAssignee = 'xxx'
def swAssignee = 'xxx.'
def testAssignee = 'xxx'

Collection allsubtasks = issue.getSubTaskObjects()
for(Issue allsubtask: allsubtasks) {
def subtaskSummary = allsubtask.getSummary()
log.info("Subtask Summary" + subtaskSummary)
if (subtaskSummary == (compare with ?){
log.info("Subtask already exists")}
else {
m119VersionArray.each{ version ->
createSubTask("", version, "_Approved_REQ", reqAssignee)
createSubTask("", version, "_Approved_SW", swAssignee)
createSubTask("", version, "_Approved_TEST", testAssignee) }
}
}d 

 

Suggest an answer

Log in or Sign up to answer