Hi All,
I'm looking to add a post function to a Jira workflow that sets the date in a custom field to a 1 month from now,
I have now idea idea how to do this, but something that seems quite simplistic in my head, ie. Date = date+30, seems to be unnecessarily complicated in Jira.
I have the script-runner add-on together with the standard Jira functionality, any ideas where to start?
Your help is greatly appreciated.
Tom
Hi All,
Based on what's been said above I now have the below code:
import com.atlassian.jira.component.ComponentAccessor
import java.sql.Timestamp
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
def csDate2 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Forecast Date")
Timestamp csDate1Value = (Timestamp) issue.getCreated()
Date csNewDateValue = new Date(csDate1Value.getDate());
csDate2.updateValue(null, issue, new ModifiedValue("", (Object) csNewDateValue), new DefaultIssueChangeHolder())
This is not working and am getting the error "org.ofbiz.core.entity.GenericTransactionException: Commit failed, rollback previously requested by nested transaction."
I'm also not sure where the one month or 6 month, etc time period is defined above, this doesn't appear to make a lot of sense based on what i'm reading.
Please can anyone advise?
I don't understand why this is so hard.
1.create a custom field for user to set the desired date
2.create a script that reads the current date and create a function to add 6 months from the current date that is given by the user
3.try printing the changed date data to the variable and to another custom field or to the same custom filed
hope this help
try the script runners documentation for the this process i would suggest you to use behaviours from the scriptrunner
https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
PLease refer below link. It is similar question. It may help you.
def csDate2 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Approved On")
Timestamp csDate1Value = (Timestamp) issue.getCreated()
Date csNewDateValue = new Date(csDate1Value.getTime() + 30*24*60*60*1000);
csDate2.updateValue(null, issue, new ModifiedValue("", (Object) csNewDateValue), new DefaultIssueChangeHolder())
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
So i have the below.
import java.sql.Timestamp
import com.atlassian.jira.issue.ModifiedValue
def csDate2 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Forecast Date")
Timestamp csDate1Value = (Timestamp) issue.getCreated()
Date csNewDateValue = new Date(csDate1Value.getTime() + 30*24*60*60*1000);
csDate2.updateValue(null, issue, new ModifiedValue("", (Object) csNewDateValue), new DefaultIssueChangeHolder())
Getting the error: Unable to resolve class DefaultIssueChangeHolder
Any ideas?
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.