How to Share User Properties between Google Apps Script Projects

How to Share User Properties between Google Apps Script Projects

The Properties Service of Google Apps Script is utilized by designers to store application setup and client explicit settings. The properties information is checked to a particular client, or a particular undertaking, and can’t be divided among various ventures.

The Email Form Notifications add-on likewise utilizes the Properties Service to store decides that are characterized by the client. The standards made by User An are not available to User B.

Notwithstanding, in some particular cases, we might need to offer admittance to our store information to another client so they may expand upon the current setup as opposed to building everything without any preparation.

The new import trade choice permits the client to send out properties information as a plain book document that can be brought into the property store of another client.

Access the Property Store

On the worker side (Google Script), we characterize two techniques – one for sending out information as a JSON record and the other strategy for bringing in information from the property store of another client into our own.

/* Choose DocProperties for editor add-ons */
const getStore = () => {
  return PropertiesService.getUserProperties();

/* Export user settings */
const exportUserData = () => {
  const data = getStore().getProperties();
  return JSON.stringify(data);

/* Import user settings */
const importUserData = (data) => {
  const json = JSON.parse(data);
  return 'OK';

Export User Properties as a Text File

For exporting data, the HTML file contains a simple download button that connects to the server, fetches the data and allows the user to save this data as a text file on their computer.

<p>Export Data</p>
<button onclick="downloadFile();return false;" href="#">Export</button>

  function downloadFile() {
      .withSuccessHandler(function (data) {
        var a = document.createElement('a');
        var blob = new Blob([data], {
          type: 'text/plain',
        var url = URL.createObjectURL(blob);
        a.setAttribute('href', url);
        a.setAttribute('download', 'file.txt');;

Import User Properties from a Text File

For importing data into the property store, the user can upload a text (JSON) file that contains data as key-value pairs. These files are easily readable in any text editor and you can also add define new properties by adding new keys to the JSON file.

<p>Import data</p>
<input type="file" id="file" accept="text/plain" />

    function (event) {
      var file =[0];
      if (file.type !== 'text/plain') {
        window.alert('Unsupported file');
      var reader = new FileReader();
      reader.onload = function (e) {
          .withSuccessHandler(function (success) {
          .withFailureHandler(function (err) {

The File Reader API of JavaScript is utilized to peruse the substance of the chose text document. The onload occasion gets terminated when the document has been effectively perused in memory.

The readAsText technique for File Reader will peruse the document as a string yet you may likewise utilize the readAsDataURL strategy ought to be wish to transfer record in base64 encoded design that can be decoded on the worker.

Leave a Reply

Your email address will not be published. Required fields are marked *