How to make a "dynamic" open page command?

Hi guys!

I’ve got this challenge where I want to change which page opens (after a button click) based on certain criteria.
I know there’s this “if function” which could help to make this happen, but I have like 30 options, meaning I should make 30 IF scenarios in the IF function (bit too much for me).

Though, I can make an API call which could tell the app what page to open, but not sure how to get that in the “open page” command then, as you can only select page IDs, not app variables or whatever.

Please let me know

Open Page wont accept dynamic page names, so you are going to have to literally IF test each thing.

Thanks John.

Not the answer I was fishing for, but better have the truth haha

Is there no way we couldn’t build a new more dynamic Open Page module? I really want to open pages dynamically too. For me its so I can have a limited set of pages and navigate through them based on a data set rather than hard wiring them.

The only alternative would be to use IF logic to select different Open Page nodes.

1 Like

Yes, I guess so. Feed a variable to a a number of IF statements each of which links to the desired Open Page. Messy, but it achieves the same thing.

I am thinking of using. JS node with switch statement. Have not tried yet.

1 Like

It worked!

Add a JS node

In JS Node add four outputs. Set Output 1 as below. Do the same for the rest.

BTW, output 4 will be the errorMessage.

image

Then write the code in below


switch (inputs.input1.toUpperCase()){
case "PAGE1":
  return [0, {option1: "PAGE1"}];
  break;

case "PAGE2":
  return [1, {option2: "PAGE2"}];
  break;

  case "PAGE3":
  return [2, {option3: "PAGE3"}];
  break;

default:
  return [3, { errorMessage: "ERROR - NOT FOUND" }];

}

image

Cheers

1 Like