Hi,
I have a piece of code on Scriptrunner post function Jira workflow;
if (elite.status == 201) {
final customfieldID = 'customfield_10289'
final newFieldValue = 'Success'
put("/rest/api/2/issue/ITS-53")
.header('Content-Type', 'application/json')
.body([
fields: [
(customfieldID): newFieldValue
]
]).asString()
} else {
final customfieldID = 'customfield_10289'
final newFieldValue = 'Fail'
put("/rest/api/2/issue/ITS-53")
.header('Content-Type', 'application/json')
.body([
fields: [
(customfieldID): newFieldValue
]
]).asString()
}
I want to define the issue key (ITS-53) as the current issue key that I run when I transition the current issue key and so the post function (scriptrunner) works.
how to replace the hardcoded issue key to the current issue key?
Thanks
Hi Rika,
If you are using the Post-Function, you should use the Issue's key variable, i.e. (issue.key), to dynamically set the current issue key.
To see which keyword you can use, click on the question mark symbol as shown in the image below:-
Once the question mark symbol is clicked, you will be shown the in-build variables as shown in the image below:-
So, in your code, instead of using:
put("/rest/api/2/issue/ITS-53")
you could use:-
put("/rest/api/2/issue/${issue.key}")
I hope this helps to answer your question. :)
I am looking forward to your feedback.
Thank you and Kind Regards,
Ram
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.