Hello,
If the custom field "Due Date" is not empty, the date from this field should be entered into the field "Comments" with some text like this:
MyText: DueDateValue
Which code can I use to do that?
Many thanks in advance.
Regards
Leo
Hi @Leo Epstein do you need to insert the code during transition or right on the screen before the transition is executed?
Hi @Martin Bayer _MoroSystems_ s_r_o__ ,
I need the code for a Post Function in the Create Issue Transaction.
Regards,
Hi @Leo Epstein , cool. Adaptavist has a library of code snippets. You can go for insipration there.
The code needed to create new comment is here: https://library.adaptavist.com/entity/add-comment-to-an-issue-in-a-post-function
You also need to load Due Date value (https://docs.atlassian.com/software/jira/docs/api/8.22.0/com/atlassian/jira/issue/Issue.html#getDueDate--), you can do it using:
def dueDateValue = issue.getDueDate()
dueDateValue is of Timestamp type here, so you need to convert it to String:
So in sum it should be something like:
def dueDateValue = issue.getDueDate()if(dueDateValue){ def dueDateString = new SimpleDateFormat("MM/dd/yyyy").format(dueDateValue) // the body of the comment final String commentBody = """MyText: ${dueDateString}""" // the author of the comment will be the logged in user def author = ComponentAccessor.jiraAuthenticationContext.loggedInUser ComponentAccessor.commentManager.create(issue, author, commentBody, false)}
Thanks a lot for your kind suggestions.
I cannot see the name of my field "Due Date" in your code.
Will that work anyway?
It looks like you're new here. Sign in or register to get started.