Loop not working on Pavlovia

(PsychoPy version 2024.2.4)

Hello everybody. I have created an experiment on Builder that works seamlessly locally. On Pavlovia, however, one of the loops is not working and I get an undefined variable error message.
The stimuli in that loop are drawn from several Excel files dynamically (I had to create different lists for randomization). The randomization code is just before the loops in a routine by itself. The stimuli files are present in the repository and I am pretty sure they are loaded correctly, however I believe something goes wrong because of the code I used.

Randomization code in Java:

/// Define the list of possible choices
var list_choice_B1 = [1, 2, 3, 4];

// Randomly select one value from the list
var random_choice_B1 = list_choice_B1[Math.floor(Math.random() * list_choice_B1.length)];

// Declare conditions_file globally
var conditions_file = “”; // Ensure it exists before assignment

// Assign the correct conditions file based on the chosen value
switch (random_choice_B1) {
case 1:
conditions_file = “list_1.xlsx”;
break;
case 2:
conditions_file = “list_2.xlsx”;
break;
case 3:
conditions_file = “list_3.xlsx”;
break;
default:
conditions_file = “list_4.xlsx”;
}

// Debugging: Ensure PsychoJS recognizes the file
console.log(“Selected conditions file:”, conditions_file);
console.log(“Checking resource:”, psychoJS.serverManager.getResource(conditions_file));

// Save the chosen value in experiment data
psychoJS.experiment.addData(“conditions_file”, conditions_file);
psychoJS.experiment.addData(“chosen_listID_B1”, random_choice_B1);

The loop condition is “$conditions_file”, this works fine locally, but I have no idea whether it causes the experiment to crash online.