It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

set a custom field or DueDate as a specific time of the day Edited

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?

 

1 answer

0 votes
Thomas Deiler Community Leader Feb 02, 2018

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

Thomas Deiler Community Leader Feb 02, 2018

Dear @Ankit Patel,

best you read this article how to change a custom field.

So long

Thomas

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

Thomas Deiler Community Leader Feb 02, 2018

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

@Nic Brough @Adaptavist Supp

Can you help provide some insight on this please?

 

Thanks

Ankit

Nic Brough Community Leader Feb 06, 2018

At a glance, I see nothing wrong with Thomas' code.  Where is it failing and what is the error?

@Thomas Deiler @Nic Brough

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 

 aa.PNG

Thomas Deiler Community Leader Feb 07, 2018

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Service Desk

[ Survey ] What does the future of ITSM look like? Take our survey today!

Hi all! We’re interested in learning more about your ITSM practices - what’s the current state of your ITSM practices? What are your aspirations for your IT team in the future? Which ITSM trends ar...

214 views 0 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you