Difficulty with Switch Statement

I am trying to do my first Switch statement and I can make no sense of the error message.

See details in the screen captures below.

What am I doing wrong?

Mike
This is the code in a stored procedure
pict1

This is the error message
pict2

Hi @mdsmith1,

It looks like you're trying to do this in a SQL block of some sort. You want to use a JS Code block instead and do something like this

const infcount = {{ localStorage.values.mInfcount }}
switch(infcount) {
  case "1":
    UpdateLetter3.trigger()
    break
  case "2":
    UpdateLetter4.trigger()
    break
 default:
    UpdateLetter4.trigger()
    break
}

That should get it working.

Mike:

I have beet my head against the wall a few times and have come up with some code that works however I learned that you can not run programs from within a Case or SWITCH Statement.

The code below shows "UpdateLetter4.trigger();" in a blanked out line. This line will cause an error message that is impossible to figure out. But when it is removed, the code works fine.

I think the inability to run external code makes this feature less useful. I take it that you can use it to set values which may have some limited use.

Anyway, thanks for helping me.

Mike
pict1

Mike:

I have tried your code with Jscript and I now have it working.

I have added wait statements and now it works perfectly.

I will mark your post as a solution.

Thank you so much for helping me.

Mike
pict1

1 Like