Whilst I can set the ‘Internal’ property flag using Mutable Issue (from previous forum examples) I’d prefer to use Issue Service if possible, but I’m unable to figure out how to add the property value to the issueInputParameters method.
I've tried searching the forum plus a few variations based on the error responses, but am unable to get it to work.
The error is:
No signature of method: com.atlassian.jira.issue.IssueInputParametersImpl.addProperty() is applicable for argument types: (java.util.HashMap) values: [[sd.public.comment:{"internal":"true"}]]
Possible solutions: addProperty(java.lang.String, org.codehaus.jackson.JsonNode), hasProperty(java.lang.String)
My code is:
Map < String, JSONObject > commentPropertyInternal = new HashMap<String, JSONObject>();
commentPropertyInternal.put("sd.public.comment", new JSONObject("{\"internal\":\"true\"}"));
issueInputParameters.setComment("Created Primary Fix issue")
.addProperty(commentPropertyInternal)
def update = issueService.validateUpdate(user, issue.id, issueInputParameters)
log.debug "${update}"
if (update.isValid()) {
issueService.update(user, update)
}
I know, this was asked a long time ago, but maybe this is of use for someone.
To create internal comments using IssueInputParameters you have to provide the correct actionParameters while creating the IssueInputParameters.
import com.atlassian.jira.issue.fields.CommentSystemField
import com.atlassian.jira.component.ComponentAccessor
def issueService = ComponentAccessor.getIssueService()
// as there is no way to set action parameters, this has to be done while
// creating them
def iip = issueService.newIssueInputParameters(getActionParametersForInternalComment())
iip.setComment("Internal comment")
// ...
Map<String, String[]> getActionParametersForInternalComment() {
final String SD_INTERNAL_FIELD_NAME = "internal";
final String SD_JSON_PUBLIC_COMMENT_KEY = "sd.public.comment";
def actionParam = [
(CommentSystemField.PARAM_COMMENT_PROPERTY): ["[{key: \"$SD_JSON_PUBLIC_COMMENT_KEY\", value: {$SD_INTERNAL_FIELD_NAME: \"true\"}}]"] as String[]
]
return actionParam
}
Best,
Henning
This is awful, and very helpful, and extremely timely. Thank you.
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.