Hi Folks,
This post function seems to be inconsistent for me with the value printed being either pre-screen or post-screen.
Any ideas on what could be happening and how i could fix?
def someFakeCustomFieldId = 'customfield_123456'
def issueWithScreenChanges = get("/rest/api/2/issue/${issue.id}")
.queryString("fields", someFakeCustomFieldId)
.asObject(Map)
.body
def newValue1 = issueWithScreenChanges.fields[someFakeCustomFieldId] as String
logger.info(newValue1)
def newValue2 = issue.fields[someFakeCustomFieldId] as String
logger.info(newValue2)
Discovered that because saves from a transition are async, the values entered into the screen cannot be reliably retrieved during the post function. I was able to work around this by converting to a listener.
Try this :
def issueBody = issueWithScreenChanges.body
return issueBody.fields[someFakeCustomFieldId] as String
Also, in post function you don't need to get the issue, you can do this:
def someFakeCustomFieldId = 'customfield_123456'
def newValue1 = issue.fields[someFakeCustomFieldId] as String
logger.info(newValue1)
def newValue2 = issue.fields[someFakeCustomFieldId] as String
logger.info(newValue2)
If you take the issueWithScreenChanges object you need to add "body", but if you run the script as post function you can just take the cf from the issue object like this-
issue.fields[someFakeCustomFieldId]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Neta. You'll see that i'm already pulling body as part of issueWithScreenChanges (Line 6 of my example)
I went ahead an posted what I discovered and the solution below.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.