I have a problem that I’ve had in other situations and I don’t know how to solve it.
To understand the context, my application has courses, each course can have N modules and classes that belong to 1 module and 1 course. Each module has 1 index number to be able to sort.
When registering a module, I am using an “if” operator to see if there is already a module registered in that course. If there is already a module registered, I search for the value of the highest index in the list of modules (let’s assume that there are 3 modules in the English course with indexes 1, 2 and 3, then the new module will be registered with index 4). If there is no module in that course, it will register a course with index 1.
The problem is this: even though there is no course registered, the formula does not work because “Cannot read properties of undefined (reading ‘index’)”.
Ah, I just had an idea! What do you think if I create an action first, like “return a value”, that takes an array that contains the index list of each item and then compares it with the largest value in the returned array
all the parameters of an if formula are evaluated because it’s a function. You need to use an if else statement ina workflow or a ternary operaror in a formula to actually evaluate only one of the two options