What is the FiscalYear? Set it on form load #javascript #sharepoint


When a requestor submits a form, it should be preloaded with FiscalYear value in option control with other values/years to choose from. If its between July 1 – June 30 its the next fiscal year.


Control used here is a drop down control with preset options (2017,2018,2019) that requestors can choose from on submit.

9-15-2016 9-41-11 AM.png9-15-2016 9-40-24 AM.png

If the current month is greater than July then, set the control selected value as next year. Script below is self explanatory and this function is called on form load.

ID of the dropdown control is stored as ‘varFY’ and we use it to set the value of the field by using control.val(value to set).

function getFiscalYearForCurrentDate() {
try {
var today = new Date();
//alert(“Current Date:” + today);
var curMonth = today.getMonth();
var fiscalY = NWF$(“#” + varFY);
//alert(“Current Month:” + curMonth);
var curYear = today.getFullYear();
var setFY = “”;
if (curMonth > 6) {
//0-11 for Jan-Dec. July is 6. July is starting month of our fiscal year
setFY = (today.getFullYear() + 1).toString();//current year + 1
else { setFY = (today.getFullYear() + 2).toString() }
catch (err) { alert(err); }


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s