SharePoint: Insert List item in Folders using JavaScript

Consider a scenario that we need to store large amount of user details yearly in SharePoint Custom List by considering SharePoint Threshold Limit.

For these types of scenario, we can utilize folder structure to store yearly data. In this case, yearly data segregated with year folder and we can fetch data from list by mentioning year.

To store list item folder, we can utilize SPServices JavaScript add-on with JQuery add-on in any SharePoint site and need to use $().SPServices.UpdateListItems function. In my previous articles already explained the details about $().SPServices.UpdateListItems:

How to use SPServices to create list item inside folder:

var listName =  "AmitKumar_TestList";
 var folderName = "2017";
 var  folderPath = $().SPServices.SPGetCurrentSite() + "/Lists/" + listName + "/" + folderName;
 var newItemID="";
 
 var camlQuery = "<Batch OnError='Continue' RootFolder = '" + folderPath + "' >" +
 "<Method ID='1' Cmd='New'>"  +
 "<Field Name='FSObjType'>0</Field>" +
 "<Field Name='Title'>" + 'http://amitkumarmca04.blogspot.com' + "</Field>" +
 "<Field Name='Year'>" + folderName+ "</Field>" +
 "</Method>" +
 "</Batch>";
 
 $().SPServices({
 operation: "UpdateListItems",
 async: false,
 listName: listName,
 batchCmd: "New",
 updates: camlQuery,
 completefunc: function (xData, Status) {
 console.log('List items has been added);
 newItemID = $(xData.responseXML).SPFilterNode("z:row").attr("ows_ID");
 
 }
 });

In the above code block, we need to define the complete path of folder where we need to store the item.