title: Can lockservice for GAS work across multiple functions in the same project
body: <p>I had a problem with a script I wrote, the solution to the issue was lock service to avoid collisions with form submits. As I had no idea this would be an issue, I've had to go back and revisit old scripts.</p>
  
  <p>I have script that has a few different functions, and it passes data from one function to another. Eventually it writes data to sheet, creates a PDF, can email it and stores the PDF to a folder in google drive.</p>
  
  <p>Here's a brief example of what I mean</p>
  
  <pre><code>function firstFunction() {
  
    //Do stuff, return something
    return something;
  
    secondFunction(something);
  
  }
  
  
  function secondFunction(something) {
  
  // Do stuff, return test
  
  thirdFunction(test);
  
  }
  
  
  
  
  
  function thirdFunction(test) {
  
  // Do stuff, return that
  
  return that;
  
  fourthFunction(that);
  
  }
  
  function fourthFunction(that){
  
  
  // finish doing stuff. Write data
  
  
  }
  </code></pre>
  
  <p>I also have a separate script, that would invoke the first and iterate through a list of data, to bulk produce PDFs.</p>
  
  <p>I'm worried that if 2 people invoke the script at the same time, I'll have issues again.</p>
  
  <p>Given the example script I've given, Do I have to use LockService on each function? Or can I declare the lock in the first function and release it in the last.</p>
  
  <p>I'm also curious on how it would sit with the 2nd script that invokes the first several times. Would adding the lock service in this one be sufficient, or would I also have to add it to the second too?</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>EDIT BELOW</strong></p>
  
  <p>I just remembered I posted the real code on Code Review for advice, and boy did I get some!!
  <a href="https://codereview.stackexchange.com/questions/116973/google-app-script-to-calculate-score-card-for-a-certain-person-create-pdf-file">Code Review Post</a></p>