Woman In Tech: NAVIGATING THE DIGITAL WORLD

seeker, learner, educator and paying it forward… in short – Jigyaasu

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

Posted by

·

, , , ,

Requirement:

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.

Solution:

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();
//alert(curYear);
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() }
fiscalY.val(setFY);
}
catch (err) { alert(err); }
}

 

Swetha Sankaran, Microsoft MVP(2017-2020) | Gen AI enthusiast Avatar

About the author

Hi! My name is Joan Smith, I’m a travel blogger from the UK and founder of Hevor. In this blog I share my adventures around the world and give you tips about hotels, restaurants, activities and destinations to visit. You can watch my videos or join my group tours that I organize to selected destinations. [Suggestion: You could use the Author Biography Block here]

Discover more from Woman In Tech: NAVIGATING THE DIGITAL WORLD

Subscribe now to keep reading and get access to the full archive.

Continue reading