PARAMETORS Component¶
List of main folders¶
var YearFolder;
var TEMPLATEFOLDER;
var BSURVEYFOLDER;
var DATABRIDGEFOLDER;
var CANALYSISFOLDER;
var OTHERFOLDERID;
var XSLFORMFPOLDERID;
Function setApiSettings¶
-
setApiSettings
(pkey)¶ The function sets the API settings from PARAMETERS sheet
- Arguments
pkey (Object) – the list of key properties and their values
- Returns
keyinputs – the list of key parameters
function setApiSettings(pkey) {
key = pkey;
var para = ss.getSheetByName("PARAMATERS");
var data = para.getRange(1, 1, para.getLastRow(), 1).getValues();
for (var i = 0; i < data.length; i++) {
if (data[i][0] == "TEMPLATE API KEY") { keyinputs["APITOKEN"] = data[i + 1][0]; }
if (data[i][0] == "SURVEY API KEY") { keyinputs["APITOKEN2"] = data[i + 1][0]; }
if (data[i][0] == "Username (Template Account)") { keyinputs["TUSERNAME"] = data[i + 1][0]; }
if (data[i][0] == "Automatic Mode from") { keyinputs["AUTOYEAR"] = data[i + 1][0]; }
if (data[i][0] == "Automatic Mode Up to:") { keyinputs["AUTOYEAR2"] = data[i + 1][0]; }
if (data[i][0] == "OTHER FOLDER ID") { keyinputs["OTHERFOLDERID"] = data[i + 1][0]; }
if (data[i][0] == "XSL FORM FOLDER ID") { keyinputs["XSLFORMFPOLDERID"] = data[i + 1][0]; }
if (data[i][0] == "MAIN FOLDER") { keyinputs["MAINFOLDER"] = data[i + 1][0]; }
if (data[i][0] == "SURVEY PLAN FORM ID") { keyinputs["SURVEYPLANFORMID"] = data[i + 1][0]; }
if (data[i][0] == "SECTOR") { keyinputs["SECTOR"] = data[i + 1][0]; }
}
return (keyinputs);
}
Function displayKeyListing¶
-
displayKeyListing
(pkey, pk)¶ The function displays the list of key properties from PARAMETRS sheet
- Arguments
pkey (Object) – the list of key properties and their values
pk (Array) – the list of key properties
- Returns
keyinputs – the list of key parameters
function displayKeyListing(pkey, pk) {
key = pkey;
k = pk;
var para = ss.getSheetByName("PARAMATERS");
var query = para.getRange(1, 4).getValue();
para.getRange(1, 5, para.getLastRow(), 2).clear();
var data = para.getRange(1, 5, k.length, 2).getValues();
var count = 0;
for (i = 0; i < k.length; i++) {
if (query != "" && String(k[i]).indexOf(query) == -1) { continue; }
data[count][0] = k[i];
data[count][1] = key[k[i]];
count++;
}
para.getRange(1, 5, k.length, 2).setValues(data);
return (keyinputs);
}
Function setKey¶
-
setKey
(pkey)¶ The function sets a key property from PARAMATERS sheet
- Arguments
pkey (Object) – the list of key properties and their values
- Returns
keyinputs – the list of key parameters
function setKey(pkey) {
key = pkey;
var para = ss.getSheetByName("PARAMATERS");
var data = para.getRange(1, 5, para.getLastRow(), 2).getValues();
for (i = 0; i < data.length; i++) {
keyinputs[data[i][0]] = data[i][1];
}
return (keyinputs);
}
Function deleteKey¶
-
deleteKey
()¶ The function deletes a key property from PARAMATERS sheet
- Returns
data – List of key parameters
function deleteKey() {
var para = ss.getSheetByName("PARAMATERS");
var data = para.getRange(1, 5, para.getLastRow(), 2).getValues();
return (data);
}
Function displayEmailQuota¶
-
displayEmailQuota
()¶ The function displays the remaining daily email quota
- Returns
msgBox – message
function displayEmailQuota() {
Browser.msgBox("The remaining daily email quota is " + MailApp.getRemainingDailyQuota());
}
Function makeBackupParemetr¶
-
makeBackupParemetr
(pkey, pk)¶ The function makes a backup of all the parameters on Backup sheet.
- Arguments
pkey (Object) – the list of key properties and their values
pk (array) – the list of key properties
function makeBackupParemetr(pkey, pk) {
var para = ss.getSheetByName("Backup");
var lr = para.getLastRow() + 1;
para.getRange(1, 1, lr, 2).clear();
var data = para.getRange(1, 1, pk.length + 1, 2).getValues();
var count = 0;
data[count][0] = "Last Backup";
data[count][1] = new Date();
count++;
for (i = 0; i < pk.length; i++) {
data[count][0] = pk[i];
data[count][1] = pkey[pk[i]];
count++;
}
if (count > 0) { para.getRange(1, 1, pk.length + 1, 2).setValues(data); }