Jump to content

If no filter matches, do this (else)


Recommended Posts

Posted

Hi,

 

i'm sry but i was unable to find it. I'm only trying to do the following:

 

If it matches x, open browser with that subsite

if it matches nothing, open browser with that site

If it matches nothing from above, open browser and do search

 

How do i click something like this together?

Posted (edited)

Simplest way is to have two filters, copies of the ones that already exist but with is not equal to instead. Like so.


Also notice that on the Keyword you need to set Argument Optional or you won’t be able to activate the empty case.

Edited by vitor
Updated Workflow link
Posted

Puh that might be a lot of work though. I was planning to do it for a few nodes like 10-20. A mix of 'go to, otherwise search' for our corporate portal.

 

There is no better solution to this, right? Would it be possible to write its own function block to implement such a 'switch' block?

Posted (edited)

Yes, you can use a Script Filter or Run Script object and choose from several scripting languages to write a switch block. Just return the corresponding URL and connect it to an Open URL object.

Edited by Tsunami
Posted

I meant more like a meta object. Similiar to filter or junction.

 

A switch statement which asks every following node if it filter did match and if not, uses the default path.

Posted
30 minutes ago, Tsunami said:

you can use a Script Filter or Run Script object

 

A Script Filter would be inappropriate for this, as it should act immediately after the Keyword.

 

15 minutes ago, sigi said:

I meant more like a meta object. Similiar to filter or junction.

 

No, there’s no such object. Do you need help writing the code for the Run Script? It’s simple enough that you should be able to understand what’s going on even with no coding experience.

Posted

Thanks vitor but i will figure it out :). I do write code as a profession.

 

I was just hoping to stay in the visual workflow editor part as long as possible.

Posted

There is something else you might try. You’ll notice Filter has a matches regex case. Thought a does not match regex would be more straightforward in this case, that limitation can be circumvented with a negative lookahead. So let’s say you don’t want to match flower, power, and empty strings: ^(?!flower|power).+$.

Posted

Its still quite cumbersome to extend it. For extension, i would need to add another filter or another entry in the regex which than becomes longer and more unreadable :(

Posted
5 minutes ago, sigi said:

Its still quite cumbersome to extend it.

 

It is. It’s also easier to mess up (especially for non-coders) which is why I hadn’t mentioned it earlier. Given the constraints, the Run Script is your best option.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...