Uploaded image for project: 'SR for Jira - Development'
  1. SR for Jira - Development
  2. SRJIRA-2341

Setting linked issues field as not required in behaviours does not unmark the field as required

    Details

    • Type: Bug
    • Status: Done
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: 5.0.14
    • Fix Version/s: 5.3.0
    • Component/s: Behaviours
    • Labels:
      None
    • Environment:

      JIRA Software: Version 7.4.1

      ScriptRunner: Version 5.0.14

    • Sprint:
      Sprint 37 - Ends Nov 28
    • Critical Points:
      1.7

      Description

      I have experienced an issue related to, but in stark contrast to SRJIRA-2333 in which there are issues manipulating the Issue Links form field with behaviours. 

      Notably, the bug that I experience is that I am able to set the Issue Links field as required with formField.setRequired(true) (showing the red asterisk), but when I set it to "not required" via the same method with a value of false, the red asterisk does not disappear.

      I've noticed that upon setting the Issue Links field to required, this exception is thrown in the Chrome console:

      batch.js?agile_global_admin_condition=true&healthcheck-resources=true&is-server-instance=true&is-sy…:7722 Uncaught TypeError: Cannot read property 'fieldType' of undefined
          at HTMLLabelElement.validateRequiredField (batch.js?agile_global_admin_condition=true&healthcheck-resources=true&is-server-instance=true&is-sy…:7722)
          at HTMLLabelElement.dispatch (batch.js?locale=en-US:104)
          at HTMLLabelElement.h (batch.js?locale=en-US:96)
          at Object.trigger (batch.js?locale=en-US:101)
          at HTMLLabelElement.<anonymous> (batch.js?locale=en-US:117)
          at Function.each (batch.js?locale=en-US:54)
          at init.each (batch.js?locale=en-US:47)
          at init.trigger (batch.js?locale=en-US:117)
          at addFieldListeners (batch.js?agile_global_admin_condition=true&healthcheck-resources=true&is-server-instance=true&is-sy…:7722)
          at Object.<anonymous> (batch.js?agile_global_admin_condition=true&healthcheck-resources=true&is-server-instance=true&is-sy…:7723)

      The same exception specified in SRJIRA-2333.

      To test this, create a behaviour on the Resolution field and use a serverside script similar to:

      import com.atlassian.jira.component.ComponentAccessor
      import com.atlassian.jira.config.ResolutionManager
      
      def resolutionManager = ComponentAccessor.getComponent(ResolutionManager)
      
      def resolution = getFieldById(getFieldChanged())
      log.warn("Resolution Value: "+resolution.value.id)
      def currentResolution = resolutionManager.getResolution(resolution.value.id as String).name
      def linkedIssue = getFieldById("issuelinks")
      
      if(currentResolution == "Done")
      {
          resolution.setRequired(true)
          linkedIssue.setRequired(false)
      }
      else if(currentResolution == "Won't Do")
      {
          resolution.setRequired(false)
          linkedIssue.setRequired(true)
      }
      else
      {
          resolution.setRequired(true)
          linkedIssue.setRequired(false)
      }

      Using log statements, I've found that the Linked Issues field is actually being set to "required" and "not required" properly. But when the exception is thrown in the console, you are unable to continue with submitting the form and the red asterisks are not removed.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jechlin Jamie Echlin
              Reporter:
              aderossett Aidan Derossett
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: