2 Conditions need to be met to show

Questions about and code samples for adding visibility conditions within Select
Post Reply
hcastaneda
Posts: 7
Joined: Fri Feb 17, 2023 11:19 am

2 Conditions need to be met to show

Post by hcastaneda »

I am trying to get a folder to show if the property is in KY and the Underwriter is FA. I have tried this and it seems to be only looking at the state. It will display regardless of the underwriter lookup code.

# Get state for first property.
state = Order.Properties[0].Address.State

# Return True if there is a state object and it matches.
return state and state.Code == 'KY'

# Show if LookupCode is "FA"
return Order.Underwriters[0].LookupCode == 'FA'

How do I get it to look at both?
BobRichards
Posts: 1377
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: 2 Conditions need to be met to show

Post by BobRichards »

The easiest way, when you have a bunch of conditions that need to ALL be true, is create individual tests where you set a separate flag for each result status. Then at the very end, AND all the tests together in an IF statement.

Code: Select all

# Get state for first property.
state = Order.Properties[0].Address.State

# (1) Set flag to true if there is a state object and it matches.
isState = state and state.Code == 'TX'

# (2) Set flag to true if first underwriter has a LookupCode of "aaa"
isUnderwriter = Order.Underwriters.Count > 0 and Order.Underwriters[0].LookupCode == 'aaa' 

# Combine all flags and return result of all tests.
return isState and isUnderwriter
Sorry I took so long to get back to you! I had a little miscommunication on my part. Take care.
Bob Richards, Senior Software Developer, SoftPro
hcastaneda
Posts: 7
Joined: Fri Feb 17, 2023 11:19 am

Re: 2 Conditions need to be met to show

Post by hcastaneda »

This worked perfectly! Thank you!!
Post Reply