Our new Appfire Documentation Space is now live!

Take a look here! If you have any questions please email support@appfire.com

Set the assignee of an issue based on time in a specific time zone

When working with teams spread across multiple time zones, it may be necessary to automatically assign an issue based on the current time in a specific time zone. This becomes complicated when the time zone to be used for assignment is not necessarily the same time zone for the user who creates the issue.

This article provides the Groovy code snippet to accomplish this using the Set field value post-function.

 Instructions

  1. In Jira Administration, go to Workflows and click the Edit link to open the workflow.

  2. Select the required transition.

  3. Select the Post functions tab and click Add post function.

  4. Select the “Set field value (JMWE app)” post-function and click Add.

  5. Set the following fields:

    1. Field: “Assignee”

    2. Value type: “Groovy Expression”

  6. Add the following Groovy script under Value:

    import org.joda.time.DateTimeZone import org.joda.time.DateTime DateTimeZone zone = DateTimeZone.forID("Asia/Calcutta"); def timeNow = new DateTime(zone) def hour = timeNow.hourOfDay if(hour >= 13 && hour <=18) return "john" else if(hour >= 19 && hour <=23) return "james" else return "alex"


    In this above script, the time zone used is “Asia/Calcutta”. This value should be updated as required; refer to https://en.wikipedia.org/wiki/List_of_tz_database_time_zones (using the value from the TZ database name column) for the timezone format accepted in the script.

    The issue will be assigned to:

    1. user “john” if the ticket is created between 1:00 PM IST and 07:00 PM IST.

    2. user “james” if the ticket is created between 7:00 PM IST and 12:00 AM IST.

    3. user “alex” if the ticket is created between 12:00 AM IST and 1:00 PM IST.

  7. Click Add and publish your workflow.

References