1
0
-1

There is a possibility to limit the attachments imported with the incoming script. The following line works fine.

issue.attachments = replica.attachments.findAll { attachment -> attachment.filename.endsWith(".pdf") }


When we only want to accept .pdf and .txt I changed it into

issue.attachments = replica.attachments.findAll { attachment -> attachment.filename.endsWith(".pdf",".txt") }


unfortunately this gives an error. Is it possible to define multiple file extensions?

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hey, Ron Becker

      Thanks for asking on community!
      You could do it with ||  operator or the array list check:

      issue.attachments = replica.attachments.findAll { attachment -> attachment.filename.endsWith(".pdf") || attachment.filename.endsWith(".pdf") }

      or

      issue.attachments = replica.attachments.findAll { attachment -> [".pdf",".txt"].any { ext -> attachment.filename.endsWith(ext) } }

      Happy Exalating!
      Serhiy

        CommentAdd your comment...