Hi,
Is there a way to add a duedate automatically to a issue? Must it depend on certain data, or can we just add 1 day to 1 day projects or 3 days to 3 day projects? Was thinking of using the "Behaviours Plugin" but not sure exactly how?
Two senarios:
1. issues being created via email, obviously no due date is added, can for instance if it's sent to a project that requires 3 days to work on it, add current date + 3days?
2. we would like this to be done in a workflow, so we can setup many workflows with different duedate requirements that could get populated automatically.
From my research something can hopefully be done through a script of some sort of perhaps a plugin. If there's a free way to do this, please help?
Thanks in Advance
Community moderators have prevented the ability to post new answers.
The benefit of using the behaviours plugin is that you can default the due date to 3 dates hence or whatever. Optionally you can make it readonly as well.
But the behaviours plugin does not operate on issues created by email, or by the API in general.
If you just want to set it, and not default it, I'd use a script that runs as a post-function of the creation action, eg:
issue.dueDate = new Date() + 3 // do your date logic here.
I'd also remove the due date from the create screen, otherwise you will frustrate your users when you overwrite it.
Hi Jamie, Thanks for your prompt response
How do i do this:
The benefit of using the behaviours plugin is that you can default the due date to 3 dates hence or whatever. Optionally you can make it readonly as well.
as i am unfimilar with the behaviours plugin?
Why would it not work on issues that come in via email, surely they have to conform to the assigned workflow process?
Does the automated duedate process you mention above using the behaviours plugin work within the workflow and do you add it as a post-function?
Forgive my ignorance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You'd have to read the docs... the reason it doesn't work with emailed issues is that it's purely javascript based, which is why I suggest to use a post-function script (script runner plugin) to do it.
It's possible to use both if it's really necessary.
> Does the automated duedate process you mention above using the behaviours plugin work within the workflow and do you add it as a post-function?
No, you map behaviours to projects, they are orthogonal to workflows. My groovy script suggestion (which I believe is correct for you) is part of the workflow. If you prefer, substitute "your home-grown java plugin" for groovy script.
I think there are other plugins that can set a date using some simple arithmetical rules.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If I would perfer to do the process in a workflow, then would I then just be using groovy in the post-function with a script runner instead of using the behaviours plugin.
Or
If I use the Behaviours plugin, it would be per project that I set the duedate and restrict user input for this field, but this won't work for incoming emails?
am I correct in saying this?
Secondly,
With your code:
issue.dueDate = new Date() + 3
Could I not add something like:
If issue.dueDate = null
then issue.dueDate = new Date() + 3
else get.dueDate.value from input data as per regular workflow or whatever the code is using groovy?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> am I correct in saying this?
Mostly. You can apply the same behaviour to multiple projects then use some server-side code to control what the actual value of the due date should be. You could base that on project or any other information.
> Could I not add something like
Absolutely, use any logic you like...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not sure what you're looking for exactly...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry Jamie, Where exactly can I find such Documentation on
The benefit of using the behaviours plugin is that you can default the due date to 3 dates hence or whatever.
I've read through some of documentation found here, but no luck?
https://studio.plugins.atlassian.com/wiki/display/JBHV/JIRA+Behaviours+Plugin
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Alright, where would I go to get more information on the behaviours plugin and adding the duedate through using the behaviours plugin?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'd read the docs and some of the other questions here, go through the examples. Having done that you'd see how to set the due date in the form. I don't think you want the behaviours plugin though, for the email reason.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not sure what you mean by the post-function area... this should be a "groovy custom post-function", with that code. Can you attach a screenshot>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie, I am now trying to accomplish this task via the behavior plug-in. In the server side script area, I added these line of code: def today = new Date() def targetDate = today + 90 FormField dueDate = getFieldByName("Due Date") dueDate.setFormValue(targetDate) However, the dueDate field is not updated as expected. I appreciated any help or direction you can provide. Tuan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is how you can set the due date: getFieldById("duedate").setFormValue((new Date() + 7).format("dd/MMM/yy")) You should look up the date format that the user will use though. You need to also check the field is empty before updating it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie, Thank you for getting back to me. Based on your suggestion, I rewrote the codes as follow in the behavior serverside script window: FormField dueDate = getFieldById("duedate") if (dueDate.getValue() == null) { dueDate.setFormValue((new Date() + 7).format("dd/MMM/yy")) } However, the dueDate field is not updating the value as expected. Do you see anything wrong with my code? Tuan btw, happy holiday; I appreciate your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
your code is pretty much the same code. Try without the if() statement. If that doesn't work change the log level to debug from the "admin -> behaviours" page, then retry the action, and post what is logged in atlassian-jira.log.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Isn't this exactly what you are looking for https://answers.atlassian.com/questions/116511/creating-a-read-only-due-date-field-that-auto-populates-when-creating-an-issue?
See @Mizan 's reply in that post.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Renjith,
It is but it isn't, I don't want it to work as per issue or by priority type, but perhaps by project.
But it could work on a similiar concept. Would be nice if Mizan could comment on this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That is a minor change Warren. Just changed Mizan's code. I have not tested it.
import java.sql.Timestamp import com.atlassian.jira.issue.MutableIssue // initializing the projects def PA = 1; def PB = 2; def PC = 3; def PD = 9; def PE = 30; // calender which returns the date according to the project 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 project = issue.projectOject.name; def setDueDate = mutableIssue.getDueDate(); //only set the dueDate if the date isn't already set (i.e. if it == null). GregorianCalendar cal; if(project.equals("PA")){ cal = getDate(PA); } else if(project.equals("PB")){ cal = getDate(PB); } else if(project.equals("PC")){ cal = getDate(PC); } Timestamp dueDate = new Timestamp(cal.getTimeInMillis()); 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.
With this code would i require any additional plugins for it to work?
Got this error:
javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: projectOject for class: com.atlassian.jira.issue.IssueImpl Possible solutions: projectObject
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
change projectObject to getProjectObject()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I now get this issue?
javax.script.ScriptException: java.lang.NullPointerException: Cannot invoke method getTimeInMillis() on null object
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That is for @Mizan to comment ;)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That script is not written very well. It means that getDate was called. It looks like it is matching on project key, in which case it should be issue.projectObject.key. Also it should have an else {} block otherwise you will get this NPE.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm trying something different.
I managed to get the "Created" Date copied into the "Due" Date field, now i want to try right a post-function to add X day/s to the due date field.
I tried to use something like this
def newDueDate = (getCreatedDate + 3)
issue.dueDate?.before(newDueDate)
but got this error?
javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: getCreatedDate for class: Script8
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use issue.getCreated() or issue.created
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok This Validates true:
def newDueDate = (issue.getCreated() + 3)
issue.dueDate?.before(newDueDate)
But this will only check whether the condition is true, How do i get it to perform the action?
Any suggestions?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That was there in the earlier code I guess,
MutableIssue mutableIssue = (MutableIssue) issue;
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.
Ah, it is much more complicated that that. You need to put that into a script - read the big blue banner at https://studio.plugins.atlassian.com/wiki/display/GRV/Script+Runner#ScriptRunner-Conditions%2CValidators%2CPostFunctions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm just checking to see if i understand,
This:
MutableIssue mutableIssue = (MutableIssue) issue;
mutableIssue.setDueDate(dueDate);
Helps this action to perform?:
def newDueDate = (issue.getCreated() + 3)
issue.dueDate?.before(newDueDate)
In the workflow through a post-function, but which post-fuction should i select?
Add Parameters To Function |
|
Add required parameters to the Function.
|
|
Built-in Scripts |
Adds a comment to all blocked issues when this issue is transitioned. Send a custom email Fast-track transition an issue Clones an issue and links. Transition parent when all subtasks are resolved Create a sub-task. Fires an event when condition is true Adds the current user as a watcher |
or | |
Script file path: | <input style="margin: 0px; padding-top: 0px; padding-bottom: 0px;" type="text" name="filename" value="" size="100" maxlength="255"/> |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Alright Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Or how about a Listener using Jamie's plugin to automatically set a due date whenever and issue is created? Jamie, comments?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, that would work fine too. A listener is the same as a post-function (in essence) except separated from the workflow.
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.