I have a map of slide numbers with an array of associated variables.
const slidesMap = {
0: ['firstName', 'date'],
10: ['diversityScore', 'diversityDef', 'butyrateEfficiency', 'propionateEfficiency'],
15: ['bacteria_1_three', 'bacteria_1_three_def', 'bacteria_2_three', 'bacteria_2_three_def', 'bacteria_3_three', 'bacteria_3_three_def'],
16: ['bacteria_1', 'bacteria_1_def', 'bacteria_2', 'bacteria_2_def', 'bacteria_3', 'bacteria_3_def'],
18: ['bacteria_10', 'bacteria_10_def', 'bacteria_11', 'bacteria_11_def', 'bacteria_12', 'bacteria_12_def', 'bacteria_13', 'bacteria_13_def','bacteria_14', 'bacteria_14_def', 'bacteria_15', 'bacteria_15_def'],
};
I have a map of variables generated from a spreadsheet,
const variablesMap = new Map();
const generalValues = sheet.getRange('A1:B20').getValues();
generalValues.forEach(row => {
variablesMap.set(row[0], row[1]);
});
Then I populate the necessary slides with necessary variables.
for (const page in slidesMap) {
const variables = slidesMap[page];
let newSlide = slides[page];
let shapes = newSlide.getShapes();
shapes.forEach(shape => {
variables.forEach(variable => {
shape.getText().replaceAllText(`{{${variable}}}`,variablesMap.get(variable), true);
});
});
}
When I log the variables in the loop, I have everything I need both in variablesMap and in slides map. Also the page numbers are correct.
What I get, is half populated slides. For example on slide 15 4/6 variables are populated. {{bacteria_1_three_def}} and {{bacteria_3_three}} are still as placeholders.
What am I missing?
On slide 18 it’s even worse. all the ..._def
are populated, but bacteria_...
are as placeholders.
I am loosing my head.
I tried logging, everything seems correct.