1
0
-1

Hi Community,


I am working on an internal connection on Jira on-prem.

AffectsVersion(s) is a mandatory field in one of the projects (by validator in workflow).

I want to set it to a default version "Default_Version". 

Somehow this code does not work:

issue.projectKey = "XY"
issue.affectedVersions += nodeHelper.getVersion("Default_Version", nodeHelper.getProject(issue.projectKey))


I receive an error message like: Can't set version object to java.util (unfortunately I can't access the tool right now for the correct message).


Interesting is that 

affectedVersion = nodeHelper.getVersion("Default_Version", nodeHelper.getProject(issue.projectKey))
debug.error(affectedVersion.name)

returns "Default_Version" correctly.


Any idea? Does Exalate interfere with the validator here? Or is it just some logical mistake / typo?


Best regards,

Max

    CommentAdd your comment...

    3 answers

    1.  
      2
      1
      0

      Try this please:


          issue.affectedVersions = null
          if (replica.affectedVersions.size() == 0){
            issue.affectedVersions = [nodeHelper.getVersion("Default_Version", project)]
          }
          else{
              replica.affectedVersions.each {
                  v -> 
                  if (nodeHelper.getVersion(v.name, project))
                      issue.affectedVersions += nodeHelper.getVersion(v.name, project)
                  else
                      issue.affectedVersions += nodeHelper.createVersion(issue, v.name, v.description)
                  }
          }  


      Let me know how it goes.


      Thanks

      Majid

        CommentAdd your comment...
      1.  
        1
        0
        -1

        Thanks for your reply Syed Majid Hassan . I figured it out in the mean time: I overwrote the affectedVersions at a later point in the script -.-

        1. Syed Majid Hassan

          Nice. 
          Glad that you got it working!


        CommentAdd your comment...
      2.  
        1
        0
        -1

        Current exception thrown:

        Exalate has problems while trying to create an issue in this Jira. Details: [InvalidInputException: [Error map: [{versions=Please add a value to the required fields Affects Version/s!}]] [Error list: [[]]]

          CommentAdd your comment...