Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

257
Views
Google App Script: How to Store rowcount and modify to update stored rowcount

This is what I am trying to achieve with the function propertiesstorage():

  1. Store and save row count in property storage in google appscript.
  2. Make the stored row counts update with the new rowcounts added. For example 1st stored rowcount === 2000 + 2nd stored rowcount === 2000 = rowcounts 4000 in total.So forth and so on

Code


function rowcount()
{ 
 
  var token = getAccessToken();
  var module = "sHistory";
  var rows = 0;
  var go = true;
  var i = 1;
  var data;
  var page = 0;
  
   while (go) {
    Utilities.sleep(20000);
    data = getRecordsByPage(i,200,token,module);
    if (Number(data.info.count) < 200) 
    {
      go = false;
    };
    if ((i%10) == 0) 
    {
       go = false; 
    }
    else if (Number(data.info.page) === true)
    {
      go = true;
      
    }
    page = Number(page) + Number(data.info.page);
    rows = Number(rows) + Number(data.info.count);
    
    //Logger.log("Page " + page);
    //Logger.log("Zoho Recruit Records" + rows);
    i++;
     
   }
      return rows;   
   }

function propertiesstorage()
{

  // saving rowcount in GAS properties
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty("sHistoryRows",rowcount());
  
  //reading rowcount from GAS properties
  var scriptProperties = PropertiesService.getScriptProperties();
  var data = scriptProperties.getProperties();

  for(var key in data)
  {
    Logger.log([key,"sHistory total count "+ rowcount()]);
    
  }

  var scriptProperties = PropertiesService.getUserProperties();
  var updatevalue = userProperties.getProperty(rowcount());
  updatevalue = rowcount();
  scriptProperties.setProperty("sHistory total count",updatevalue)
  Logger.log([key,"sHistory total count "+ updatevalue])

}
}

This is the reference I am using to try and achieve this - https://developers.google.com/apps-script/guides/properties

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!