Hi,
I would like to add a post function to newly created issues to set the due date based on the priority of the issue.
I have tested out a groovy script from an author called "mizan" but it fails to work for me as I get errors in the logs, plus the script seems to have down the rounds on a few forums and been chopped and changed etc so hard to know what isa clean working version.
Hopefully someone has a nice solution to this?
Thanks,
David
Investigatiing more, I relalised the priority names had been changed from the default. I updated the script and it worked fine.
Thanks for your input.
David
Has anyone out there successfully made this work? I have seen several different people post very similar scripts but all the comments say they still get errors.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just guessing but it seems that you are trying to calculate the time based on the system time / creation time? The object you are trying to adress obviously doesn't exist yet. When do you fire that post function? Maybe before the issue has been created and indexed? Try to set the post-function to be the last action...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And I guess posting the script wouldn't be a bad idea either ;-)
Cheers Christian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Christian,
I'm hoping to set the due date on the creation of the issue. I will hide the due date field from the create issue screen so users can't set it.
Cheers,
David
The code is below;
import java.sql.Timestamp import com.atlassian.jira.issue.MutableIssue // initializing the priority def BLOCKER = 1; def CRITICAL = 2; def MAJOR = 3; def MINOR = 9; def Trivial = 30; // calender which returns the date according to the priority defined private GregorianCalendar getDate(double roll) { Calendar cal = Calendar.getInstance(); cal.setFirstDayOfWeek(Calendar.MONDAY); cal.set(Calendar.HOUR_OF_DAY,0); cal.set(Calendar.MINUTE,0); cal.set(Calendar.SECOND,0); cal.set(Calendar.MILLISECOND,0); for (int x=0;x<roll;x++) { cal.add(Calendar.DAY_OF_MONTH,1); } return cal; } MutableIssue mutableIssue = (MutableIssue) issue; def priority = mutableIssue.getPriority().getString("name"); def setDueDate = mutableIssue.getDueDate(); //only set the dueDate if the date isn't already set (i.e. if it == null). GregorianCalendar cal; if(priority.equals("Critical")) { cal = getDate(CRITICAL); } else if(priority.equals("Major")) { cal = getDate(MAJOR); } else if(priority.equals("Minor")) { cal = getDate(MINOR); } Timestamp dueDate = new Timestamp(cal.getTimeInMillis()); mutableIssue.getPriorityObject(); mutableIssue.setDueDate(dueDate);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you checked the order of your post-functions?
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.
if you hide the field in field configuration then you can't set value to that field
!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rambanam,
To confirm, the due date field is visible for the create, Once I had this working I was goign to atempt to hide it. I have also checked the screens and the due date field is visible for "view" and "edit".
Thanks,
David
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
just for confirmation,did you tried by adding post function before create issue function?
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.
Hi Timothy,
the error I get starts with the below;
2013-08-29 10:38:53,088 http-8090-2 ERROR user1 638x187x1 1ksoqu2 10.99.0.103,127.0.0.1 /secure/CreateIssueDetails.jspa [onresolve.jira.groovy.GroovyRunner] The script failed : javax.script.ScriptException: javax.script.ScriptException: java.lang.NullPointerException: Cannot invoke method getTimeInMillis() on null object 2013-08-29 10:38:53,091 http-8090-2 ERROR user1 638x187x1 1ksoqu2 10.99.0.103,127.0.0.1 /secure/CreateIssueDetails.jspa [onresolve.jira.groovy.GroovyFunctionPlugin] Error executing post-function javax.script.ScriptException: javax.script.ScriptException: java.lang.NullPointerException: Cannot invoke method getTimeInMillis() on null object .jira.web.action.issue.CreateIssueDetails.createIssue(CreateIssueDetails.java:95)
Thanks,
David
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So? What is the error?
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.