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

This widget could not be displayed.

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 widget could not be displayed.

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 Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

220 views 3 0
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