I want to set the valuie of custom field "Remediation Deadline+= Created date +30 days using post function. Can someone please suggest how to go-ahaed i tried with the script runner but the same is not working.
Hello,
It would be something like this
import com.atlassian.jira.component.ComponentAccessorimport java.sql.Dateimport java.sql.Timestampimport com.atlassian.jira.issue.util.DefaultIssueChangeHolderimport com.atlassian.jira.issue.ModifiedValuedef csDate2 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Remediation Deadline")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()))
@Alexey Matveev
Hi Alexey,
Getting the below error after running ths script in the script console. Also do let me know how to execute the above script as a psot function .
2017-12-20 05:23:23,225 WARN [common.UserScriptEndpoint]: Script console script failed:org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:Script88.groovy: 13: expecting EOF, found ')' @ line 13, column 113.ew DefaultIssueChangeHolder()));
Script must be like this
import com.atlassian.jira.component.ComponentAccessorimport java.sql.Dateimport java.sql.Timestampimport com.atlassian.jira.issue.util.DefaultIssueChangeHolderimport com.atlassian.jira.issue.ModifiedValuedef csDate2 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Remediation Deadline")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())
Go to your workflow and add the Script Post Function post function. Choose there Custom Script Post-Function and paste the script above.
I am doing that only but somehow when i pasted the code and click on add its processing only and not going ahead.
The is a field script file , we need to provide which path in this field? pfa screen shot for the same.
Hi Shrikant,if your looking for SIL code.Try this one:%customfield_id%="created + "30d";Thank you,Randy
Hi Randy,
Where is this meant to go?
Is this for a script runner post-function?
I've tried this but it fails at '%'
Try to read on SIL documentation you can use this plug in on your back end part of jira.
https://confluence.cprime.io/display/SIL/Variable+resolution
It looks like you're new here. Sign in or register to get started.