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

Scripted Field "Preview" doesn't retrieve right value for other scripted field

    Details

    • Type: Bug
    • Status: Triage (View Workflow)
    • Priority: Low
    • Resolution: Unresolved
    • Affects Version/s: 6.2.1-p5
    • Fix Version/s: None
    • Component/s: Scripted Fields
    • Labels:
      None
    • Critical Points:
      0.6

      Description

      When user trying to preview the value for a scripted field value, it doesn't shows the right amount.

      Steps to reproduce it

      1. Create a new scripted field and add this simple script for calculation of two numbers fields A and B
        import com.atlassian.jira.bc.issue.IssueService;
        import com.atlassian.jira.component.ComponentAccessor;
        import com.atlassian.jira.issue.Issue;
        import com.atlassian.jira.issue.MutableIssue;
        import com.atlassian.jira.issue.fields.CustomField;
        import com.atlassian.jira.issue.search.SearchResults;
        import com.atlassian.jira.user.ApplicationUser;
        import com.atlassian.jira.bc.issue.search.SearchService
        import com.atlassian.jira.jql.parser.JqlQueryParser
        import com.atlassian.jira.web.bean.PagerFilter
        import com.atlassian.jira.event.type.EventDispatchOption
        
        def customFieldManager = ComponentAccessor.getCustomFieldManager()
        
        def cfSize = customFieldManager.getCustomFieldObjectsByName("A")
        
        def cfSizeVal
        cfSize.each{cf-> cfSizeVal= cf.getValue(issue)
        }
        
        def cfValue = customFieldManager.getCustomFieldObjectsByName("B") 
        def cfValueVal
        cfValue.each{cf1 ->
        cfValueVal= cf1.getValue(issue)
        }
        
        if ((cfSizeVal != null ) && (cfValueVal !=null))
        {    
            return (double)cfValueVal/(double)cfSizeVal
        }
        else
            return null
        
      2. Preview shows the right amount:
      3. Now, create another scripted field with the script below to retrieve the scripted field value from step 1:
        import com.atlassian.jira.component.ComponentAccessor
        
        def value = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_10704").getValue(issue) as Double
        
        log.warn value
        
        return value
        
      4. Previews shows NULL value:
      5. However, when viewing the value on the issue view screen, the numbers are showing correctly.

        Attachments

          Structure

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              jloong John Chin Loong
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:

                  Structure Helper Panel