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.
Hi Shrikant,
if your looking for SIL code.
Try this one:
%customfield_id%="created + "30d";
Thank you,
Randy
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
It would be something like this
import com.atlassian.jira.component.ComponentAccessor
import java.sql.Date
import java.sql.Timestamp
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
def 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()))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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()));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Script must be like this
import com.atlassian.jira.component.ComponentAccessor
import java.sql.Date
import java.sql.Timestamp
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
def 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexey,
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You do not need to provide the Script File. You should paste the script and wait until the flickering circle becomes red or green. If it is green you can push the add button.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The circle is neither turning green nor red
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try to use a different browser
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Getting the below error message while running the above script in the post function - please help
Time (on server): Wed Dec 20 2017 08:07:25 GMT-0500 (Eastern Standard Time)
The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.
2017-12-20 08:07:25,062 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************
2017-12-20 08:07:25,226 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: null, actionId: 1, file: <inline script>
java.lang.NullPointerException: Cannot invoke method getTime() on null object
at Script2.run(Script2.groovy:13)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That is strange. It means that issue.getCreated() returned no value. Where did you add the post function?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
At the create post function. pfb screen shot of the workflow, Once the issue is created i need to autmoatically populate the Remediation deadline date = Created date +30 days.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You should put your post-function last. It would be much help if you attach a screenshot with all post-functions for the create transition.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi i have changed the position of thw work flow, pfb screen shot, can you let me know how the issue key will be passed? Since it is a post function it will automatically take the Issue key, pfb screen shot -
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After you changed the position did it work?
In post functions the variable issue is passed automatically. You can get Issue key by calling
issue.getKey()
In your post-function.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexey,
Its running but taking the one month old date. Ideally it should be one month ahead of the creation date.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ideally as per the logic it should take one month ahead date but its taking the one month old date
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.
Yes, my guess is that your server time is wrong
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.