Building a Vacation Request Form with Interval Calculations
Asked by Enrico Mancuso:

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:** {#toc-hId--2124405751}

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:** {#toc-hId-363107082}

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:** {#toc-hId--1444347381}

* 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?** {#toc-hId-1043165452}

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! ?


Answers:
author: Olha Yevdokymova_SaaSJet
body: Hello [@Enrico Mancuso](/t5/user/viewprofilepage/user-id/5166724)

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](https://marketplace.atlassian.com/apps/1227085/smart-jira-forms?hosting=cloud&tab=overview&utm_source=Atlassian_Community&utm_medium=refferal&utm_campaign=Comment_Building-a-Vacation-Request-Form-with-Interval-Calculations_19092024), focusing on how to best use forms within issues versus shared forms.

### **Native Jira Features:** {#toc-hId--2124340437}

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](https://marketplace.atlassian.com/apps/1227085/smart-jira-forms?hosting=cloud&tab=overview&utm_source=Atlassian_Community&utm_medium=refferal&utm_campaign=Comment_Building-a-Vacation-Request-Form-with-Interval-Calculations_19092024): Different Approaches** {#toc-hId-363172396}

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** {#toc-hId-1053733870}

1. **Setting Up the Form:**

   * Create fields for Start Date, End Date, Leave Days, and Total Vacation Days within [Smart Jira Forms](https://marketplace.atlassian.com/apps/1227085/smart-jira-forms?hosting=cloud&tab=overview&utm_source=Atlassian_Community&utm_medium=refferal&utm_campaign=Comment_Building-a-Vacation-Request-Form-with-Interval-Calculations_19092024). 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](https://marketplace.atlassian.com/apps/1227085/smart-jira-forms?hosting=cloud&tab=overview&utm_source=Atlassian_Community&utm_medium=refferal&utm_campaign=Comment_Building-a-Vacation-Request-Form-with-Interval-Calculations_19092024) to automatically add the form to new issues in a dedicated vacation project with [Automatic Form Addition to a Jira issue](https://saasjet.atlassian.net/wiki/spaces/FORMS/pages/2119663617/Automatic+Form+Addition+to+a+Jira+issueatlOrigin=eyJpIjoiYjM3N2FkNjBmYjU1NGNkMWI5Y2RjMDE1ZTJkNjc1MzgiLCJwIjoiYyJ9)  
     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](https://community.atlassian.com/t5/image/serverpage/image-id/348659iAB54B0D63F54F89D/image-size/large?v=v2&px=999 "295f3d30-71b4-4ac4-8d11-c526a1301377.png")
3. **Using Update existing issue fields:**

   * The ["**Update existing issue fields**"](https://saasjet.atlassian.net/wiki/spaces/FORMS/pages/2578972704/Destination+Field+for+form+in+issueatlOrigin=eyJpIjoiZDlhMDBmMmNmY2E3NDVlMmI0ODQwZGFkMjRlMjZkMWUiLCJwIjoiYyJ9) 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](https://community.atlassian.com/t5/image/serverpage/image-id/348658i3E70D84A8A0667BE/image-size/large?v=v2&px=999 "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)** {#toc-hId--753720593}

1. **Form Setup and Sharing:**

   * Share the form externally through a link or embed it on Confluence using [Smart Jira Forms](https://marketplace.atlassian.com/apps/1227085/smart-jira-forms?hosting=cloud&tab=overview&utm_source=Atlassian_Community&utm_medium=refferal&utm_campaign=Comment_Building-a-Vacation-Request-Form-with-Interval-Calculations_19092024)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](https://marketplace.atlassian.com/apps/1227085/smart-jira-forms?hosting=cloud&tab=overview&utm_source=Atlassian_Community&utm_medium=refferal&utm_campaign=Comment_Building-a-Vacation-Request-Form-with-Interval-Calculations_19092024) uses the ["Create Issue"](https://saasjet.atlassian.net/wiki/spaces/FORMS/pages/2510454789/Create+a+Jira+issue+based+on+the+submitted+formatlOrigin=eyJpIjoiZGE1ZjkzYWQ5MDliNDU5NTk3YTQ2NjBhYjJjYzM3NmQiLCJwIjoiYyJ9) 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](https://community.atlassian.com/t5/image/serverpage/image-id/348660i9F4AC4CE65DAA8A3/image-size/large?v=v2&px=999 "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](https://marketplace.atlassian.com/apps/1227085/smart-jira-forms?hosting=cloud&tab=overview&utm_source=Atlassian_Community&utm_medium=refferal&utm_campaign=Comment_Building-a-Vacation-Request-Form-with-Interval-Calculations_19092024) 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](https://community.atlassian.com/t5/image/serverpage/image-id/348661iA7669B0BE90AD73C/image-size/large?v=v2&px=999 "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](https://community.atlassian.com/t5/image/serverpage/image-id/348662i8F26FB41396BAF59/image-size/large?v=v2&px=999 "1c91e695-f7e4-48e7-acfa-a7bb52ec1b8b.png")

### **Key Differences:** {#toc-hId--764223697}

* **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:** {#toc-hId-1723289136}

* **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.


Tags: confiforms

confluence-data-center

data-center