I have this function that runs when user logs on:
function InitialSetup(five, context, result) {
five.log('InitialSetup');
// save userKey
const userKey = five.currentUserKey();
five.setVariable("UserKey", userKey);
// save current date as formatted string
const today = new Date(five.now());
const formattedDate = today.toLocaleDateString('en-US', {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric'
});
five.setVariable("CurrentDate", formattedDate);
// save fiscal year start date
let fyStartMo = 7;
let yr = today.getFullYear();
let mo = today.getMonth() + 1; // month is 0-based, so add 1 before comparing to fy start month
if (mo < fyStartMo) {
yr -= 1;
}
five.setVariable("FyStartDate", new Date(yr, (fyStartMo - 1), 1));
// set any needed variables
five.setVariable("AddMode", false);
const joinTableMap = {
Reports: 'ReportMembers',
StudyGroups: 'StudyGroupMembers',
Portfolios: 'PortfolioMembers'
};
const setupForms = [
'ReportsSetup',
'StudyGroupSetup',
'PortfolioSetup'
];
five.setVariable('JoinTableMap', joinTableMap);
five.setVariable('SetupForms', setupForms);
return five.success(result);
}
When I run Five and log on, then open the inspector, I see this for JoinTableMap variable:
"JoinTableMap":string"{"Reports":"ReportMembers","StudyGroups":"StudyGroupMembers","Portfolios":"PortfolioMembers"}"
So this isn’t working. When I log the variable, I get this:
"JoinTableMap: \"{\\\"Reports\\\":\\\"ReportMembers\\\",\\\"StudyGroups\\\":\\\"StudyGroupMembers\\\",\\\"Portfolios\\\":\\\"PortfolioMembers\\\"}\""
This seems to confirm that the variable is actually a string instead of a JSON object.
How did I go wrong? Thanks…

