Application (Record Producer) Submission during the Specific Months

Mittal_M
Giga Guru

I have a use case for submitting the application for users from ESC portal, I created a record producer.

The requirement is that application submissions should only be allowed during June-July every year and the apply (submit) button should only be clickable during that period. Outside of this period, users should still be able to access the record producer for informational purposes from the ESC portal. Also, business needs the flexibility to open/close applications on an ad-hoc basis (outside the June-July window).

 

Can anyone suggest other effective ways to achieve this use case requirement (if possible without DOM manipulation) related with the potential for ad-hoc overrides?

 

@Ankur Bawiskar @Chuck Tomasi 

Thanks
4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Mittal_M 

you should create a schedule for this which includes only 1 June to 31st July and then handle the validation using onSubmit

OR

You can use onSubmit validation script and see if today's date is between 1 June to 31st July, if yes then stop the form submission and show alert, Don't hide the submit button as it will require DOM manipulation

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur Bawiskar , Thanks for your response.

Yes, we can restrict users to submit the request using onSubmit script however, users still have to put the efforts to fill the form which is not a good experience from customer's pov.

 

Alternative is that we can make all the variables readonly if it's outside of Jun-Jul period by using "g_form.setVariablesReadOnly(true)" in client script but again that is not working on ESC portal. here is the script FYI.

 

function onLoad() {
    //Type appropriate comment here, and begin script below
    var currentDate = new Date();
    var currentMonth = currentDate.getMonth();

    alert('currentMonth : ' + currentMonth);
    // Define the application period (June-July)
    var applicationStartMonth = 5; // June
    var applicationEndMonth = 6; // July

    // Enable/disable the button based on the current date
    if (currentMonth != applicationStartMonth || currentMonth != applicationEndMonth) {
        alert('inside IF condition');
        g_form.setVariablesReadOnly(true);
    }
}


As I mentioned initially there are two parts to achieve

1. submissions should only be allowed during June-July every year. Outside of this period, users should still be able to access the request for information on ESC portal.

2. Business needs the flexibility to enable/disable the application request on ad-hoc basis (outside Jun-July) without making significant config changes.

 

Thanks

@Mittal_M 

if you want to have good user experience then simply hide that item using User Criteria during that time frame.

Then they need not fill and wait for validation

What's the point of showing that form if they are not meant for submission during that period?

You can do this ( the best approach I could think of)

1) use onLoad catalog client script and validate using Ajax the time period

2) if it's within that period, show alert and redirect user to the portal homepage

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Mittal_M 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader