I have a situation where one of my stakeholder is asking to setup the duedate / duetime (a custom field) to setup SLAs.
They want a specific time of the day to be set as a duetime,
Example, for an issue type ABC, the default due time is 12pm on that day. So any ticket created at 2am and 6am for issuetype ABC will have sla due time as 12pm.
Is this possible on Jira Service Desk, I am using scriptrunner so any feedback would be helpful.
Thanks
Ankit
UPDATE
Since duedate is only a date field, can someone suggest how we can set this as a custom field?
Dear @Ankit Patel,
to better understand, when (in the life cycle of an issue) you would like to set a specific date?
And you can not make a system field like Due Date to a custom field. Create a new one with a different name.
So long
Thomas
so for example if I have created a ticket today at 2am, then I want to it to set a due-time (custom-field) as 12pm of the same day. how do i do that using scriptrunner?
Thanks Thomas
Ankit
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 Thomas,
I not aware of the code, so I would need some help if you can elaborate on hot can i set this up. From the link you have provided, i see that the script s for a listener, how do i get it so setup a specific time of the day?
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor
def issue = event.issue as Issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def tgtField = customFieldManager.getCustomFieldObjects(event.issue).find {it.name == "My CustomField"}
def changeHolder = new DefaultIssueChangeHolder()tgtField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(tgtField), "myvalue"),changeHolder)
Any help would be much appreciated
Thanks
Ankit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear @Ankit Patel,
I have coding skills, but I am not familiar with script runner functionality. However I adapted the upper script to your needs:
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor
import java.util.Date.*
import java.util.SimpleDateFormat.*
import java.util.GregorianCalendar.*
// create a today date + time with modified to 23:59
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss a")
Calendar calendar = new GregorianCalendar()
calendar.set(Calendar.HOUR_OF_DAY, 23)
calendar.set(Calendar.MINUTE, 59)
def issue = event.issue as Issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def tgtField = customFieldManager.getCustomFieldObjects(event.issue).find {it.name == "My Own Due Date"}
def changeHolder = new DefaultIssueChangeHolder()tgtField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(tgtField), sdf.format(calendar.getTime())),changeHolder)
Unfortunately I have not ScriptRunner installed, so I cannot verify the upper scripts' functionality.
If you have bought this Plugin, I recommend to ask the vendors' professional support to assist.
So long
Thomas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Nic Brough -Adaptavist- @Adaptavist Supp
Can you help provide some insight on this please?
Thanks
Ankit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
At a glance, I see nothing wrong with Thomas' code. Where is it failing and 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.
@Thomas Deiler @Nic Brough -Adaptavist-
Thank you for the help so far
I am getting the below error when I try to run this in script runner
The script could not be compiled:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script193.groovy: 10: unable to resolve class SimpleDateFormat @ line 10, column 18. SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss a")
^ Script193.groovy: 10: unable to resolve class SimpleDateFormat @ line 10, column 24. SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss a") ^ 2 errors
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear @Ankit Patel,
the groovy compiler cannot find the class java.util.SimpleDateFormat. I do not know the details of your build environment, but I guess that there is for sure some documentation how to import native Java classes.
So long
Thomas
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.