JIRA Service Desk 4.13.2 (Jira Server)
Hello,
I am using "ScriptRunner >> Jobs >> Escalation service" to add a comment to a group of issues with a JQL Query. I would like to add the value of a custom field of type Date / Time to the comment, but in "Additional issue actions" I can only add a comment:
issueInputParameters.setComment ('Write your comment here')
How can I also add a Date / Time type field to the comment?
Someone could help me?
Thanks
Hi @Prueba Cliente Edu I think you just need to
It should be somethinkg like:
def dateCustomField = ComponentAccessor.customFieldManager.getCustomFieldObjectByName(fieldName)
def dateCustomFieldValue = issue.getCustomFieldValue(dateCustomField)
def simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd")
def dateAsString = simpleDateFormat.format(dateCustomFieldValue)
issueInputParameters.setComment (dateAsString)
Hi, @Martin Bayer _MoroSystems_ s_r_o__
Thank you very much for your answer.
I have done what you told me, but it gives the following error:
Also, if possible, I would like to include a free text in the comment, in addition to the date value. How could I do it?
Something like this: The date is: <dateAsString>
Thanks again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Prueba Cliente Edu , you need to
import java.text.SimpleDateFormat
and fix your code new simpleDateFormat to new SimpleDateFormat
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.
Hi, @Martin Bayer _MoroSystems_ s_r_o__ , Now I have other errors:
I am barely aware of "groovy", sorry for the inconvenience.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Prueba Cliente Edu you just need to add another import
import com.atlassian.jira.component.ComponentAccessor
It will solve first error. The other error is only static type check of groovy and it will work without resolving it.
The issue here is that Groovy does not use object types as strictly as Java do...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have already modified it, but I have another error when executing:
2021-04-08 11:38:36,262 ERROR [jobs.EscalationService]: Escalation Service (Prueba Escalada) failed for issue BBVA-10
groovy.lang.MissingPropertyException: No such property: created for class: Script25
at Script25.run(Script25.groovy:4)
My groovy code that I am running is this:
import com.atlassian.jira.component.ComponentAccessor
import java.text.SimpleDateFormat
def dateCustomField = ComponentAccessor.customFieldManager.getCustomFieldObjectByName(created)
def dateCustomFieldValue = issue.getCustomFieldValue(dateCustomField)
def simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd")
def dateAsString = simpleDateFormat.format(dateCustomFieldValue)
issueInputParameters.setComment (dateAsString)
Can you help me, please?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah, your code
def dateCustomField = ComponentAccessor.customFieldManager.getCustomFieldObjectByName(created)
is wrong. You need to set custom fields name as the parameter of the method getCustomFieldObjectByName. It should be something like
def dateCustomField = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Name of my field")
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.