0

I developed numbers of custom scripts in a project which supposed to run over lastrow of data in response sheet linked to a gform upon submission of that gform. When tested, it took around 45 seconds to finish all the custom scripts.

Now here is where I get worried and I'm looking for a firm answer which I still cannot find from google search. Within that 45 seconds of processing, other gform users can submit the form and I'm thinking every latest submission will be taken as lastrow of data in the response sheet.

So, since my custom scripts will always refer and/or getValue(s) on the lastrow of response sheet, will that makes some of my scripts will jump on to the latest row of data before it finishes the previous one just because the latest submission is before the 45 seconds is finished? I'm so worried that if it is yes, that definitely will make the output become a disaster.

Add Info. I have one main function that calls other subfunctions chronologically and some subsubfunction(s) been called from that subfunction. Please refer below:-

function MAINFUNCTION(){
var sheet=SpreadsheetApp.getActiveSheet();

MYfunctionA();
MYfunctionB();
MYfunctionC();

}

MYfunctionB(){

//something done here..

mysubfunctionB();
return
}

MYfunctionA(){

//something done here..

return
}

MYfunctionC(){

//something done here..

return
}

So, if LockService is the solution, must it be applied to every subfunction? Another thing, what will happen if there's a google service/server error during that locktime? will it release the lock and proceed with the next record?

Or will it auto-retry? Because during testing, sometimes I got this service/server error prompted and usually I just rerun it back, but I wonder what will happen if this project is launched and used by many users almost concurrently?

dell
  • 171
  • 13
  • 2
    Related: `LockService` – TheMaster Sep 24 '20 at 23:23
  • okay..am looking into that now.. I still don't get which one that `LockService` class I should use and where to use it. Anyone can help to give samples, please? – dell Sep 24 '20 at 23:26
  • okay.. I found one sample of similar scenario. [impelement `LockService`](https://stackoverflow.com/questions/43223774/how-to-understand-lockservice-and-implement-it-correctly) . will try on that one. – dell Sep 24 '20 at 23:36
  • Hi, @TheMaster, since I have one main function that consists of all the external functions, should I apply this `LockService` to every other external function as well? or it is enough to just create the lock at the main function? And how about the other subfunction(s) inside that external function? – dell Sep 25 '20 at 00:52
  • 2
    Main function should be enough – TheMaster Sep 25 '20 at 02:32
  • Ok @TheMaster. Noted. Will try on that one ASAP. Tq – dell Sep 25 '20 at 05:16

0 Answers0