Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

I am trying to autopopulate a field with hour of the day

shankara vijayendran
Contributor
March 17, 2023

when a issue is created based on the created time the field "Timer for resolution" should be autopopulated only with hour of the day 

say created time is 13.00.00 

The field should populate with 13

3 answers

2 votes
Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 17, 2023

Hi @shankara vijayendran ,

consider using Automation smartvalue as below. You can use mediumtime possibly?

{{[date].[dateformat]}}

Takes a date and time that you provide, and returns it in a format of your choosing. This is useful for converting the default output for dates (jiraDateTime), to a format that is easier to read. You can add a dateformat to the end of any of the date smart values listed on this page.

The full list of formats are below:

Format

Thursday, November 1, 1979 6:23:12 AM UTC

Default (none specified)

1979-11-01T11:23:12.0+0000

jiraDate

1979-11-01

jiraDateTime

1979-11-01T06:23:12.0-0500

jqlDate

1979-11-01

jqlDateTime

1979-11-01 06:23

shortDate

11/1/79

shortTime

6:23 AM

shortDateTime

11/1/79 6:23 AM

mediumDate

Nov 1, 1979

mediumTime

6:23:12 AM

mediumDateTime

Nov 1, 1979 6:23:12 AM

longDate

November 1, 1979

longTime

6:23:12 AM EST

longDateTime

November 1, 1979 6:23:12 AM EST

fullDate

Thursday, November 1, 1979

fullTime

6:23:12 AM EST

fullDateTime

Thursday, November 1, 1979 6:23:12 AM EST

format("<pattern>") e.g. format("dd/MM/yyyy")

Refer to the Java documentation for pattern syntax.

01/11/1979

0 votes
habib rahman
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 19, 2023

Hi @shankara vijayendran - My name is Habib maybe this might also help.

 

To autopopulate the "Timer for resolution" field in Jira Software with only the hour of the day based on the created time of the issue, you can create a post function that extracts the hour from the created time and sets it as the value of the custom field. Here's how you can achieve this:

  1. Navigate to the Jira Software project where you want to configure the post function and go to the "Project settings" page.
  2. Click on the "Workflows" option in the left-hand menu and select the workflow that is associated with the issue type you want to configure.
  3. Click on the transition where you want to add the post function. A transition is an action that moves an issue from one status to another, such as "Open" to "In Progress".
  4. Click on the "Post functions" tab and click on the "Add post function" button to add a new post function.
  5. Select the "Script Post-Function" option from the list of available post functions.
  6. In the "Script" section, enter the following script:
```
import java.time.LocalTime;def createdTime = issue.getCreated();
def hour = LocalTime.from(createdTime).getHour();
issue.setCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Timer for resolution"), hour);

```In this script, we first retrieve the created time of the issue using the `getCreated()` method. We then use Java's `LocalTime` class to extract the hour component of the created time using the `getHour()` method. Finally, we set the value of the "Timer for resolution" custom field to the extracted hour using the `setCustomFieldValue()` method.
7.Save the post function and publish the workflow changes.
Now, when an issue is created or transitioned through the transition where you added the post function, the "Timer for resolution" field will be autopopulated with the hour of the day based on the created time of the issue.
I hope this has also helped.
Thank you Habib 
shankara vijayendran
Contributor
March 19, 2023

Hello Habib

Greetings
The post function is not available for our version I guess

May be our plan too
Can you let me know Which plan your using

Thanks

Shankar 

0 votes
Juan Carlos Vera
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 17, 2023

@shankara vijayendran 

In your case you can inform de Field in Automation with this value:

{{issue.created.format("H")}} 
shankara vijayendran
Contributor
March 19, 2023

time in hours.png

shankara vijayendran
Contributor
March 19, 2023

Hello Juan Carlos Vera,

I have attached the image of a ticket 
It shows as 4 hours in Time hours 
Can you let me know Y 
Thanks

Have a nice day 

Shankar

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events