cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ele2
Helper I
Helper I

Trouble making a nested if statement in a foreach loop

I'm trying to make a foreach loop where PAD runs a subflow when the variables "Charlie", "Jane" and "Mark" don't appear on the webpage. This is how I've written it, but I'm pretty sure it's wrong as it's not working. (PAD always runs the subflow regardless). How should it be written instead? Thanks.

Screenshot (17).png

4 REPLIES 4
MichaelAnnis
Super User
Super User

I am surprised it is running the subflow at all. %Browser2% is a web instance, not a string of text, so none of these would ever be satisfied.

 

This is how I read what is displayed above:
IF Browser2 = ‘Charlie and Jane, but not Mark’ THEN Run Subflow1. 


I would change all the ifs to “does not contain”. It might be more than that though. Like I said, %Browser2% is a web instance which has specific properties such as URL.  You can see the properties by referencing the variable via the variable drop down inside the parameters and clicking on the drop down arrow next to the variable name. I am not sure what you intend to compare these names to:  is it a specific field? Is it in the URL?  You may need to extract text somewhere and then compare against that. Otherwise, your format works (with one caveat, remove the else if function) if you change them to ‘does not contain’, for example, if you are comparing against the URL:

 

If %Browser2.Address% does not contain ‘Charlie’

    If %Browser2.Address% does not contain ‘Jane’

        If %Browser2.Address% does not contain ‘Mark’

            RunSubflow1

        EndIf

    EndIf

Endif

 

 

 

 

VJR
Super User
Super User

And to bring it in a single line and combine all the "IFs" suggested by Michael use the logical AND operator per post here.

  • NotContains(VAR'KEY', False)

@MichaelAnnis So would it be something like this?

Screenshot (18).png

I think Browser2 would need to be the property field on the webpage like you said - but I don't know how to make it into a variable (I can only get it as a UI element). 

 

I'm trying to see if the webpage has selected one of the names in the dropdown box below: 

Screenshot (12).png

 

@VJR Thanks I'll take a look at that. 

so, I think you are on the right track. If it is a specific field, such as “manager”, then you can get the field value as a variable and then compare the field variable. So, if you have the field as a UI element, you want to “get element attribute” for the action and the attribute you want is called “Own Text”. Once you have that as a variable, you can replace all the %Browser2% variables with the %OwnText% variable. Good luck!

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Top Solution Authors
Top Kudoed Authors
Users online (1,903)