Building a Vacation Request Form with Interval Calculations

Enrico Mancuso September 19, 2024

Hi Community,

I'm working on a vacation request form in ConfiForms and need some assistance with a few key features I can't seem to get working properly. Here's what I'm trying to achieve:


My Requirements:

  1. Employee Entry Fields: The form should allow employees to enter just the date-time interval (start and end) and assign a substitute. This information should be displayed in a Calendar View for easy visualization of their vacation.

  2. Leave Days Calculation: Based on the interval, the system should automatically calculate the number of leave days and subtract it from the default annual entitlement of 30 days.

  3. Remaining Leave Display: I want to show the remaining leave days after each vacation entry using valueView. For example, if an employee uses 5 days, the next time they view the form, it should display their remaining leave (25 days in this case).

  4. Dynamic Remaining Leave for Future Entries: When an employee submits another leave request, the form should dynamically calculate their remaining leave and subtract the new request from that balance, not from the default 30 days again.


Issues I'm Facing:

  1. Date-Time Interval Calculation: I'm currently using two separate dateTime fields (start and end dates) because I couldn't figure out how to use a single interval field to calculate the number of days. I need a solution where the number of vacation days is computed directly from the interval. This my calculation rule:

urlaubstage=([entry.Zeitraum2.timestamp]-[entry.Zeitraum1.timestamp])/86400000+1
=> Here I Caluculate with two DateTime field but i cant show that in an intervall in calenderView. With DateTime Intervall field it is possible but i cant calculate with it.

  1. Filtering valueView for Remaining Leave by createdBy: I can’t seem to filter the valueView correctly based on the logged-in user (createdBy) to show their remaining leave. Every user should only see their own vacation days and remaining leave.

  2. Updating the Remaining Leave Dynamically: After a user submits a vacation request, the system should store their remaining days (calculated after subtracting the current request). This value should be used as the baseline for future vacation requests, not the default 30 days.


What I've Tried So Far:

  • I’ve attempted to use two dateTime fields and calculate the difference in days, but this approach feels cumbersome and error-prone.
  • I’ve looked into valueView filters but haven’t had success in filtering by createdBy and summing the total days off taken by the user.
  • I understand there may be a need to store the remaining leave days in a hidden field for subsequent form submissions, but I'm unsure how to implement that correctly.

Any Suggestions?

Has anyone successfully built something similar? How can I:

  • Efficiently calculate leave days based on a date-time interval?
  • Filter the vacation entries by user (createdBy) and display their remaining leave dynamically?
  • Ensure that future vacation requests are deducted from their previously calculated remaining leave and not the default 30?

I'd appreciate any code snippets, configuration examples, or even alternative approaches.

Thanks in advance! 😊

2 answers

0 votes
Alex Medved _ConfiForms_
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.
September 26, 2024

Hi @Enrico Mancuso 

DateTimeInterval field in ConfiForms has handy functions to get the period between the selected dates - https://wiki.vertuna.com/display/CONFIFORMS/Accessing+field+values+and+properties

myfield.periodInSeconds

myfield.periodInMinutes

myfield.periodInHours

myfield.periodInDays

myfield.periodInWorkDays

But you can always calculate whatever you want, by accessing startDate and endDate fields of the DateTimeInterval field

Filtering by current user is possible

createdBy:[entry._user]

_user, and some other variables are always available in the context - 

https://wiki.vertuna.com/display/CONFIFORMS/Accessing+field+values+and+properties#Accessingfieldvaluesandproperties-Additionalvaluesavailableinthecontext

Alex

0 votes
Olha Yevdokymova_SaaSJet
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
September 23, 2024

Hello @Enrico Mancuso 

Jira doesn’t natively support advanced form calculations, but you can achieve basic tracking using custom fields and Jira automation. Here’s how to handle vacation requests using both native Jira and Smart Jira Forms, focusing on how to best use forms within issues versus shared forms.

Native Jira Features:

  1. Date Fields and Basic Calculation:

    • Use custom date fields (Start Date and End Date) in Jira to capture the leave period and set up Jira Automation to calculate leave days, e.g., {{issue.End Date.diff(issue.Start Date).days}}.
  2. Tracking Leave Balance:

    • Create a custom field like “Remaining Leave Days” to track each employee’s leave balance, updating it via automation rules after each request.

Using Smart Jira Forms: Different Approaches

Smart Jira Forms offers two main approaches: forms added directly to Jira issues and shared forms using the “Create Issue” feature. Each approach has unique benefits and ways to track vacation balances.

Approach 1: Forms Added Directly to Issues Automatically

  1. Setting Up the Form:

    • Create fields for Start Date, End Date, Leave Days, and Total Vacation Days within Smart Jira Forms. The “Leave Days” field will be mapped to your desired Jira field after form submission.
  2. Auto-Attach Forms to Issues:

    • Configure Smart Jira Forms to automatically add the form to new issues in a dedicated vacation project with Automatic Form Addition to a Jira issue
      This allows employees to create an issue for each vacation request and based on the issue type and project the form will be added automatically.295f3d30-71b4-4ac4-8d11-c526a1301377.png
  3. Using Update existing issue fields:

    • The Update existing issue fields feature is used to map form responses directly to fields in the Jira issue. For example, map “Leave Days” to a custom field tracking days taken, ensuring the form data syncs with Jira.9607a0b8-eabe-4a98-b24d-605e3f5041d1.png
  4. Tracking and Updating Vacation Days:

    • Track vacation balances within the issue itself using fields like “Total Vacation Days” and “Remaining Vacation Days.”
    • Use Jira Automation to update the balance each time a new request is submitted within the issue.

Approach 2: Shared Forms Using Create Issue (Link or Confluence embeded form)

  1. Form Setup and Sharing:

    • Share the form externally through a link or embed it on Confluence using Smart Jira Forms link and insert it to iframe element on your confluence page. This makes it easy for employees to submit requests outside of Jira.
  2. Using the Create issue from form submission Feature:

    • When the form is submitted, Smart Jira Forms uses the “Create Issue” feature to generate a new issue for each request. Unlike forms added to issues, each submission results in a new Jira issue auomatically created.
    • In this setup, you can select which fields from the form you want to map to the newly created Jira issue, ensuring accurate data capture.5a886662-1e4b-4038-8b4a-f8f2652223ae.png
  3. Central Tracking Issue for Vacation Balances:

    • Since each request creates a new issue, use a separate tracking issue (e.g., “Employee Vacation Tracker”) to store and manage each employee’s total vacation balance.
    • Include custom fields like “Total Vacation Days,” “Used Vacation Days,” and “Remaining Vacation Days” to keep a running total of each employee’s balance.
  4. Automation to Update the Central Tracker:

    • Set up Jira Automation to update the tracker issue each time a new request is submitted. For instance, the automation rule can subtract the “Leave Days” from the “Remaining Vacation Days” in the tracker.
  5. Link Requests to the Tracker(optional):

    • Use automation rules to link each new vacation request to the central tracker issue, keeping everything connected.

Aditional possibilities:

Analyzing Responses to Monitor Total Vacation Days Taken:

  • Utilize the “Responses” Tab in Smart Jira Forms to track all submitted forms and monitor the total days taken across requests. This helps in maintaining an overview of each employee’s usage within single interface. 8283c89f-bef4-4b1b-a516-dd1a0dfe3b68.png

Export to external tools as Exel or PDF

  • Export individual responses as Exel file to calculate Vacation days externally.1c91e695-f7e4-48e7-acfa-a7bb52ec1b8b.png 

Key Differences:

  • Destination Issue Fields: Used for forms added directly to Jira issues, mapping responses to existing fields in the issue.
  • Create Issue Feature: Used when the form creates new Jira issues, allowing you to select which form fields to map to the new issue.

Choosing the Right Approach:

  • Forms in Issues: Great for internal tracking, direct field mapping, and in-issue tracking.
  • Shared Forms with Create Issue: Best for easy access via links or Confluence, requiring a separate tracker to manage total vacation balances.

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events