Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This section has use cases which help you in understand the usage of Validators provided by JMWE.

...

  • (lightbulb) Validate that a comment is entered when rejecting a Bug fix.

    Expand
    titleSteps


    Panel

    Add the Comment required validator to the Resolve Reject transition of the Bug workflow.



...

  • (lightbulb) Block the creation of a Bug if no Attachment is provided.

    Expand
    titleSteps


    Panel
    • Add the Scripted (Groovy) validator to the Create transition.
    • Write the following in the Groovy script

      Code Block
      languagegroovy
      linenumberstrue
      try {
        return issue.get("issuetype").name != "Bug" && issue.getModifiedFields()?.get("attachment")?.getNewValue()?.size() > 0
      } catch (Exception e) {
        return false
      }




  • (lightbulb) Validate the Cascade select for values in parent and child select dropdowns

    Expand
    titleSteps


    Panel
    • Add the Scripted (Groovy) validator to the transition.
    • Write the following in the Groovy script

      Code Block
      languagegroovy
      linenumberstrue
       issue.get("Cascade")?.get(null) != null && issue.get("Cascade")?.get("1") != null




  • (lightbulb) Block the approving of the Change request if it has no confluence page linked

    Expand
    titleSteps
    • Add the Scripted (Groovy) validator to the Approve transition.
    • Write this content in the Groovy script.

      Code Block
      issue.getRemoteLinks("confluence").size() > 0


    • Type the error message in Error message, to display if the validation script returns false


  • (lightbulb) Block the approval of an issue if there is no PDF attached either from before or added during the transition

    Expand
    titleSteps
    • Add the Scripted (Groovy) validator to the Approve transition.
    • Write this content in the Groovy script.

      Code Block
      import com.atlassian.jira.issue.IssueFieldConstants
      import com.atlassian.jira.issue.attachment.Attachment
      import com.atlassian.jira.issue.attachment.TemporaryWebAttachment
      import com.atlassian.jira.issue.attachment.TemporaryWebAttachmentManager
      
      if (issue.get("attachment").any{it.filename.endsWith(".pdf")}) 
        return true;
      
      TemporaryWebAttachmentManager attachmentManager = getComponent(TemporaryWebAttachmentManager)
      try {
          List<Long> ids = issue.getModifiedFields().get(IssueFieldConstants.ATTACHMENT).getNewValue();
          if (ids)
              return ids.any { id ->
                  def attachment = attachmentManager.getTemporaryWebAttachment(id).getOrNull()
                  return attachment?.filename?.endsWith(".pdf")
              }
      } catch (Exception e) {
      }
      return false


    • Type the error message in Error message, to display if the validation script returns false


...