Hello-
We migrated from Server to Cloud, there are few scripted field which needs recreation. I am looking to recreate Last Comment Scripted field with below -
final lastCommentFieldName = 'Last Comment'
// Get last comment custom field id
def customFields = get("/rest/api/2/field")
.asObject(List)
.body
.findAll { (it as Map).custom } as List<Map>
def lastCommentCfId = customFields.find { it.name == lastCommentFieldName }?.id
// Updates the issue with the created comment body
put("/rest/api/2/issue/${issue.key}")
.header("Content-Type", "application/json")
.body([
fields:[
(lastCommentCfId): comment.body
]
])
.asString()
Result :-
groovy.lang.MissingPropertyException: No such property: issue for class: Script1 at Script1.run(Script1.groovy:12) at Script1$run.call(Unknown Source) at com.adaptavist.sr.cloud.workflow.AbstractScript.evaluate(AbstractScript.groovy:35) at com.adaptavist.sr.cloud.events.ScriptExecution.run(ScriptExecution.groovy:29) at ConsoleScriptExecution1_groovyProxy.run(Unknown Source)
Let me know what's missing