Limit submission of intake form after a certain time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi,
Is it possible to limit the submission of an intake form after it's been the first 10 days or 15 days of the month? If yes how it can be done?
Thanks in advance!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hello @Vaishali 11
Yes, it's possible by writing a Scripted User Criteria (to hide the item entirely) and On Submit Client Script (to block submission with a message), incase if admins are able to see item or sometimes cache issue causes to display item.
Script for User Criteria:
answer = checkDate();
function checkDate() {
// Get Current Date/Time
var gdt = new GlideDateTime();
// Get the Day of the Month (Local time or System time depending on requirement)
// using getDayOfMonthLocalTime() handles the user's timezone better
var day = gdt.getDayOfMonthLocalTime();
// Check if day is within the limit (e.g., 15)
if (day <= 15) {
return true; // Allow access
}
return false; // Deny access
}
function onSubmit() {
// This script checks the client date.
// For strict security, use GlideAjax to check Server Time to prevent timezone hacks.
var limitDay = 15; // Set your limit day here
var today = new Date();
var currentDay = today.getDate(); // Returns day of month (1-31)
// If today is after the limit
if (currentDay > limitDay) {
// 1. Add a prominent error message
g_form.addErrorMessage('Intake for this form is only allowed between the 1st and the ' + limitDay + 'th of the month. Submissions are currently closed.');
return false;
}
}
Below are some screenshot of working and configuration done over a catalog item named "Test Item".
Below results over portal when I impersonate with ITIL User:
Below results when I try to test item being admin I can see but we want to avoid submission in case it has cache issue or someone with admin role try to access item then result is as seen below.
If my response has helped you, hit the helpful button, and if your concern is solved, do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.
