Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,558,559
Community Members
 
Community Events
184
Community Groups

Update Summary Via scriptrunner

Edited

I am trying to update an issue summary when an issue is created. i want the summary to be what is entered in a custom field. I created the following listener when an issue is created.

 

package com.adaptavist.sr.cloud.samples.events

//def issueKey = 'TEST-137'
def reportName = 'customfield_13703'//Report Name
def projectKey = "TEST"

def input = issue.fields[reportName] as String
def output = input + " eureka!"
def sum = issue.fields.summary

logger.info("summary?: {}", sum)

put("/rest/api/2/issue/${issue.key}")
.header("Content-Type", "application/json")
.body([
fields:[
(sum): output
]
])
.asString()

 

but when creating an issue the logger gives error 

 

CorrelationId: 8a010bb7-1caa-4f62-b087-b68e529cde88
RUN Script identifier: 5c14fc0b-b94b-4b96-9665-8ec17ab24745 com.adaptavist.sr.cloud.events.WebhookExecution (jira:issue_updated webhook fired for issue TEST-141) Logs:
2017-12-26 19:43:39.341 INFO - summary?: aklsjfkadjskf;jsdk;lf
2017-12-26 19:43:40.015 WARN - PUT request to /rest/api/2/issue/TEST-141 returned an error code: status: 400 - Bad Request
body: {"errorMessages":[],"errors":{"aklsjfkadjskf;jsdk;lf":"Field 'aklsjfkadjskf;jsdk;lf' cannot be set. It is not on the appropriate screen, or unknown."}}
2017-12-26 19:43:40.017 INFO - PUT /rest/api/2/issue/TEST-141 asString Request Duration: 656ms

 

the report name field is available on the create issue screen however.

 

what else can the error message be referring to?

1 answer

0 votes
Alexey Matveev
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.
Dec 26, 2017

Hello,

I guess, it should be like this (I changed (sum) to summary). As far as I understand it must be a valid json. when you send a json you should provide

"filedname":"fieldvalue". You provided "summaryfieldvalue":"newvalue" and it was wrong.

package com.adaptavist.sr.cloud.samples.events

//def issueKey = 'TEST-137'
def reportName = 'customfield_13703'//Report Name
def projectKey = "TEST"

def input = issue.fields[reportName] as String
def output = input + " eureka!"
def sum = issue.fields.summary

logger.info("summary?: {}", sum)

put("/rest/api/2/issue/${issue.key}")
.header("Content-Type", "application/json")
.body([
fields:[
summary: output
]
])
.asString()

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events