I'm having issues setting a custom datepicker field from the groovy post function Clones an issue and links.
Condition: blank
Target Project: Different Project name
Target Issue Type: New Issue Type
Additional issue actions:
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Start Date'} issue.setCustomFieldValue(cf.id, '2012-09-17 00:00:00.0')
Issue Link Type: New Plan
Log error:
Caused by: groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.IssueImpl.setCustomFieldValue() is applicable for argument types: (java.lang.String, java.lang.String) values: [customfield_10434, 2012-09-17 00:00:00.0] Possible solutions: setCustomFieldValue(com.atlassian.jira.issue.fields.CustomField, java.lang.Object), getCustomFieldValue(com.atlassian.jira.issue.fields.CustomField)
I've also tried
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Start Date'} issue.setCustomFieldValue(cf.id, '30/Apr/13')
Log error:
Caused by: groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.IssueImpl.setCustomFieldValue() is applicable for argument types: (java.lang.String, java.lang.String) values: [customfield_10434, 30/Apr/13] Possible solutions: setCustomFieldValue(com.atlassian.jira.issue.fields.CustomField, java.lang.Object), getCustomFieldValue(com.atlassian.jira.issue.fields.CustomField)
The server shows the date picker field as DD/MMM/YY when being filled out.
I'm using version script runner 2.1.3
Thanks Jamie,
import java.sql.Timestamp def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Start Date'} issue.setCustomFieldValue(cf, new Timestamp(new Date(2012,9,17).getTime()))
That worked. I was able to construct my final piece of getting a different date picker field to populate to a different date picker field by putting the following.
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Start Date'} issue.summary = 'Equipment Order (automatic ticket)' issue.setCustomFieldValue(cf, cfValues['Effective Date'])
oh Jamie, if you could convert one of your comments to answer, I'll accept it. Thanks
And thanks to Henning for your assist
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this:
import java.sql.Timestamp issue.setCustomFieldValue(cf, new Timestamp(new Date(2012,9,17).getTime()))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think you have to use a Timestamp (or Date) object as value to set. You can easily see the needed object if you call getValue() on the customfield an examine the returned object.
log.error cf.getValue(issue).class.name
If you now look into the log you will see the needed object for setting the value.
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
alright, I 'think' that it is saying it needs a timestamp. I ran the following through the script runner at the ticket in question.
import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.CustomFieldManager CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager() issueOld = ComponentManager.getInstance().getIssueManager().getIssueObject("HR-823") def cf = customFieldManager.getCustomFieldObjectByName("Start Date") def rt = issueOld.getCustomFieldValue(cf) log.error cf.getValue(issueOld).class.name rt
and it came back with this in the log
Caused by: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: java.sql.Timestamp.getValue() is applicable for argument types: (com.atlassian.jira.issue.IssueImpl) values: [HR-823] Possible solutions: getDate(), getClass(), getDay(), getTime(), getNanos(), getTime()
and this value on the output
2012-09-17 00:00:00.0
I also dumbied down my 'Additional Issue Actions' to
issue.setCustomFieldValue("customfield_10434", '2012-09-17 00:00:00.0')
and I get this in the log
javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.IssueImpl.setCustomFieldValue() is applicable for argument types: (java.lang.String, java.lang.String) values: [customfield_10434, 2012-09-17 00:00:00.0] Possible solutions: setCustomFieldValue(com.atlassian.jira.issue.fields.CustomField, java.lang.Object), getCustomFieldValue(com.atlassian.jira.issue.fields.CustomField)
I also tried
issue.description = '\nStart Date=' + cfValues['Start Date'] + '='
to make sure the output didn't have any hidden characters or spaces. Output was
Start Date=2013-04-30 00:00:00.0=
As you can see the output is the same format as the value I'm trying to set.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I cannot reproduce your ScriptExecption, for me your script works well.
But, you have to use a Date object for setting. Currently you are using a String.
Try
new Date(2012,9,17)
as value for setCustomFieldValue()
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Start Date'} new Date(2012,9,17) issue.setCustomFieldValue(cf.id, Date)
and I got
Caused by: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.IssueImpl.setCustomFieldValue() is applicable for argument types: (java.lang.String, java.lang.Class) values: [customfield_10434, class java.util.Date] Possible solutions: setCustomFieldValue(com.atlassian.jira.issue.fields.CustomField, java.lang.Object), getCustomFieldValue(com.atlassian.jira.issue.fields.CustomField
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Start Date'} issue.setCustomFieldValue(cf.id, new Date(2012,9,17))
Try this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First off, I REALLY appreciate your help on this. I put that in and got
Caused by: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.IssueImpl.setCustomFieldValue() is applicable for argument types: (java.lang.String, java.util.Date) values: [customfield_10434, Thu Oct 17 00:00:00 PDT 3912] Possible solutions: setCustomFieldValue(com.atlassian.jira.issue.fields.CustomField, java.lang.Object), getCustomFieldValue(com.atlassian.jira.issue.fields.CustomField)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're welcome :-)
Oh, I see.. you have to use the customfield itself for setCustomFieldValue() and not the Id of the customfield. So try
issue.setCustomFieldValue(cf, new Date(2012,9,17))
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
tried your code and got
Caused by: org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:CustomFieldValue][id,6924947][datevalue,Thu Oct 17 00:00:00 PDT 3912][issue,605122][parentkey,null][customfield,10434] (Java type java.util.Date not currently supported. Sorry.)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
produced this log entry
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script2.groovy: 2: unable to resolve class Timestamp @ line 2, column 31. issue.setCustomFieldValue(cf, new Timestamp(new Date(2012,9,17).getTime())) ^
the '^' is pointing at the 'new' of 'new Timestamp'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import java.sql.Timestamp
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Jamie for pitching in (and for your vote) while I was enjoying my leisure time.. :-)
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.