I'm trying to figure out why the variable ROOT_FOLDER_LOCATION is undefined. The function is running as a google "cloud function" and it is triggered from ZOHO CRM in which it is sent URL encoded data containing the variables 'ID', 'firstName', 'lastName', 'Salesman'. I have tried getting this to work by 'awaiting' pretty much every line in the try-catch block, moving the salesmanID variable inside of the function, but it doesn't work. The salesman and workingRoot variables are both defined (salesman='Jim Schwartz' in my testing and workingRoot='abcdefgXv2'), so I don't understand why the ROOT_FOLDER_LOCATION variable is undefined.
const {google} = require('googleapis');
const axios = require('axios').default;
const FormData = require('form-data');
const SCOPES = ['https://www.googleapis.com/auth/drive'];
//IDs for client folders of salesmen
const salesmanID = {'Jim Schwartz': 'abcdefgXv2', 'Marks Shared Folder': '1M6NUf-abcdefg', 'Samanthas Shared Folder': 'abcdefgVZSMzhoVBU5wJ'};
exports.myFunction = async (req, res) => {
try{
const params = new URLSearchParams(req.body);
let zohoLeadID = params.get('ID');
let firstName = params.get('firstName');
let lastName = params.get('lastName');
let CLIENT_NAME = `${lastName}, ${firstName}`
let salesman = params.get('Salesman');
let ROOT_FOLDER_LOCATION = salesmanID[salesman];
let workingRoot = salesmanID['Jim Schwartz'];
console.log(salesman);
console.log(`workingRoot: ${workingRoot}`);
console.log(`${ROOT_FOLDER_LOCATION}`);
res.status(200).send('Success');
} catch (err) {
console.log(err);
res.status(500).send('Failed...');
}
};