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

On ajaxError causes fields override

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Done
    • High
    • Resolution: Fixed
    • 4.3.19
    • 5.0.11
    • None
    • None
    • Sprint 29 - Ends 10 May, Sprint 30 - Ends June 20, Sprint 31 - Ends June 27
    • 1.8

    Description

      Steps to reproduce

      • Create an initialiser behaviour with the following script
      import com.onresolve.jira.groovy.user.FieldBehaviours
      import static com.atlassian.jira.issue.IssueFieldConstants.*
      
      import groovy.transform.BaseScript
      
      @BaseScript FieldBehaviours fieldBehaviours
      
      def desc = getFieldById(DESCRIPTION)
      def defaultValue = """URL to JIRA project: <URL> (if exists)
      URL to Bitbucket project: <URL> (if exists)
      """.replaceAll(/ /, '')
      
      if (! underlyingIssue?.description ) {
          desc.setFormValue(defaultValue)
      }
      
      • Open the create issue dialog
      • Set throttling to your browser (3G will do the trick)
      • Edit the description
      • Start typing random in the labels field really fast - the goal is to force an ajaxError

      The description field get's overridden with the original template

      Root cause

      When there is an ajaxError we enforce the behaviours to reinitialise and therefore every field that has a behaviour will be affected.

      Workaround

      Assign the behaviour directly to the field. So for example in the above use case you should select the Description field and add as a server side script the following

      import com.onresolve.jira.groovy.user.FieldBehaviours
      import static com.atlassian.jira.issue.IssueFieldConstants.*
      
      import groovy.transform.BaseScript
      
      @BaseScript FieldBehaviours fieldBehaviours
      
      def desc = getFieldById(DESCRIPTION)
      
      def defaultValue = """
              URL to JIRA project: <URL> (if exists)
              URL to Bitbucket project: <URL> (if exists)
              """.replaceAll(/ /, '')
      
      if (! desc.getValue() ) {
          desc.setFormValue(defaultValue)
      }
      

      Attachments

        Activity

          People

            tbatagiannis Thanos Batagiannis
            tbatagiannis Thanos Batagiannis
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: