how do I access Original estimate using Scprit Runner

Jose Barbosa January 17, 2017

Hi 

 

I am trying to create a SubTask using Script Runner Post function and  I am Getting the following Error message. 

I already added the Time track  function to the Screen and  still not recognize. 

Any thoughts. Script Runner.JPG

 

2017-01-17 21:40:21,509 INFO - Serializing object into 'interface java.util.Map'
2017-01-17 21:40:21,512 WARN - POST request to https://scriptrunner.connect.adaptavist.com/jira/proxy/rest/api/2/issue returned an error code: status: 400 - Bad Request
body: [errorMessages:[], errors:[originalEstimate:Field 'originalEstimate' cannot be set. It is not on the appropriate screen, or unknown.]]
2017-01-17 21:40:21,513 INFO - POST /rest/api/2/issue asObject Request Duration: 435ms
2017-01-17 21:40:21,531 ERROR - assert resp.status >= 200 && resp.status < 300 && subtask && subtask.key != null
       |    |      |      |  |    |      |     |          |
       |    400    true   |  |    400    false false      false
       |                  |  status: 400 - Bad Request
       |                  |  body: [errorMessages:[], errors:[originalEstimate:Field 'originalEstimate' cannot be set. It is not on the appropriate screen, or unknown.]]
       |                  false
       status: 400 - Bad Request
       body: [errorMessages:[], errors:[originalEstimate:Field 'originalEstimate' cannot be set. It is not on the appropriate screen, or unknown.]]
2017-01-17 21:40:21,539 ERROR - Class: com.adaptavist.sr.cloud.workflow.CreateSubtask, Config: [className:com.adaptavist.sr.cloud.workflow.CreateSubtask, uuid:ee89ea6f-a9ab-4be5-9b21-d41a22578af8, description:Close Job  .25hrs, condition:, summary:Close Job  .25hrs, issueTypeId:5, executionUser:INITIATING_USER, additionalCode:def tasktime ="1h"
subtask.fields.originalEstimate = tasktime
def user = [name: "KellyT"]
subtask.fields.assignee = user]

2 answers

5 votes
Jon Mort [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 18, 2017

My original answer wasn't applicable in this case. You should remove overrideScreenSecurity and set the field like so:

subtask.fields.timetracking=[originalEstimate: "1w"]

Original Answer:

If you switch the user to the the "ScriptRunner Add-On User" instead of "Initiating User" it will add the overrideScreenSecurity query string and should work correctly. The change will be made by the ScriptRunner user and not by the user who made the transition however.

Jose Barbosa January 18, 2017

Thanks  for  the  Replay 

 

I change the initial user to the scriptrunner  but I got the same  error

Jon Mort [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 18, 2017

The problem actually is that originalEstimate doesn't not exist. You have to set time tracking info like so:

subtask.fields.timetracking=[originalEstimate: "1w"]
0 votes
Randy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 17, 2017

This is your issue:

errors:[originalEstimate:Field 'originalEstimate' cannot be set. It is not on the appropriate screen, or unknown.

Easiest way is to just add it to your screen. Otherwise you'll need to manually run the create by constructing a post so that you can overridescreensecurity

def resp = Unirest.put("/rest/api/2/issue/${issue.key}")
        .queryString("overrideScreenSecurity", true)
        .header("Content-Type", "application/json")
        .body(body)
Jose Barbosa January 18, 2017

image2017-1-18 8:58:34.png

 

I added  that   in the additional code but it  was still giving me the same   error

 

Is here where I should be running the   code?

Suggest an answer

Log in or Sign up to answer