how do I access Original estimate using Scprit Runner

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

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.

Thanks  for  the  Replay 

 

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

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

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

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)

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,265 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot