Ok let’s do some improvements…
At the first look the first thing i have checked was your DATASET-VARIABLE.
You do not use it consequently, this can make issues when doing it like you do.
I gave you a kind of —> USER-INTERFACE <— where you can manage easely all given and important variables, which are used alater somwhere in your (already grown-up code). Why is my suggested technique useful ???
Do you have already some ideas? No?
Ok, than let us say you have the variable —>
var DATASET =
And you also gave your DATASET-variable a VALUE → “#dataset1”
DATASET="#dataset1"
But when i look at your code, some parts uses the VARIABLE and some parts are hard-coded in the code. Every part of your code, which is hardcoded, can include (for example → TYPING-ERRORs).
You already have any idea, what i want to tell you ?
Second one what i see is → you do not have any console-logs!
How you want to find your bug, when you are not able to see what happens in CODE ?
Add almost in every code-line a understanable console.log → to investigate your own code. Then you will be able to find emidiately the issue in your code.
How to do ?
Start with a simple console.log…here your code starts…
$w.onReady(async function () {console.log("CODE-START")
$w(DATASET).onReady(() => {console.log("Dataset-Ready")
// Gets the current item properties and stores them in a variable called item
const item = $w(DATASET).getCurrentItem(); console.log("MyCurrentItem: ", item)
// Checks if the current item has a value in the field
if (!item.imada) {$w("#ImEmbajada").hide();}
if (!item.imor) {$w("#ImEmbajador").hide();}
.
.
.
.
.
Take a look onto the first implemented console-log.
Take a look onto the second implemented console-log.
Take a look onto the third implemented console-log.
If your code is not running, then it brakes somewhere on runtime, but before it breaks at a specific code-line, it will show you all the well running code-lines, with the help of the CONSOLE !
Now try to investigate your code by yourself and create console-logs at important code-lines (or even at every-code-line), to find out, at which part of your code all breaks down and you get an —> ERROR.
Good luck and happy DEBUGGING! 