Hey Gang,
So I've got some team members that are really hating the relative date format and want to see some dates in yyyy-MM-dd HH:mm ... however another team in our JIRA prefers them, and from what I can tell, relative dates are system wide.
I'm looking to create a scripted field that can pull that date and display it in yyyy-MM-dd HH:mm (it can be a text field/string, doesn't need to be into an actual date format) but I'm not sure how to do that.
Been messing around with the following...
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
def issueManager = ComponentAccessor.getIssueManager()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
def cField = customFieldManager.getCustomFieldObject("customfield_10700")
def cFieldValue = issue.getCustomFieldValue(cField)
issue.setCustomFieldValue(cFieldValue)
but I can't seem to get away from the following error
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.IssueImpl.setCustomFieldValue() is applicable for argument types: (java.sql.Timestamp) values: [2018-09-26 00:00:00.0] Possible solutions: getCustomFieldValue(com.atlassian.jira.issue.fields.CustomField), setCustomFieldValue(com.atlassian.jira.issue.fields.CustomField, java.lang.Object)
Looks like I'm pulling the value correctly but there's something about setting the value thats not working. I've tried switching the custom field template to Text Field, Date Time Picker, and Absolute date time with no luck.
Anyone able to help?
Two answers here!
1. It is possible to turn off relative dates with a simple flag in a config file - would that not be easier?
2. setCustomField needs two parameters - the custom field and the new value. Your code only gives it a value.
Hey Nic, thanks for reachin out.
1. As far as I'm aware I can't make the config file project specific, can I? This would have to be for only a single project as I mentioned some other groups need to keep it relative. Also, I'd have to wait a while. I don't have access to the config file, or a testing environment to check what needs to be done and relay it to the people who do have that access in my org, plus we're migrating our server this weekend to another datacenter and trying to get anyone to care about this is gonna be a nightmare for weeks probably.
2. I updated to the following but it's still throwing out the same error.
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
def issueManager = ComponentAccessor.getIssueManager()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
def cField1 = customFieldManager.getCustomFieldObject("customfield_10700")
def cField2 = customFieldManager.getCustomFieldObject("customfield_13434")
def cField1Value = issue.getCustomFieldValue(cField1)
issue.setCustomFieldValue(cField2, cField1Value)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I should also note I'm trying to go from a date field (cField1) to a string (cField2.. the custom Scripted Field)... i'm not sure if that's gonna throw me for a whirl or not, however, I did test and regardless if I change the custom field type to date or to string i seem to get the same thing.
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.