Visibility based on blank field

Questions about and code samples for adding visibility conditions within Select
Post Reply
RebeccahCTAC
Posts: 3
Joined: Sat Apr 27, 2019 3:14 pm

Visibility based on blank field

Post by RebeccahCTAC »

Hi all, I've gone through all of the prior postings in regards to the visibility conditions and I was able to make several of the codes work for our company, so a big THANK YOU for all that asked those questions! Python is not my first language (or second, not even in the top 10), but I've been able to piece together codes from what others have posted. Forgive me if I'm using incorrect terms.

TL:DR Is it possible to set a visibility condition based on if a field is blank?

We have two doc sets -- We'll call them "Commitment Docs (REG)" and "Commitment Docs (STD)".

At first I was looking for the set "Commitment Docs (STD)" to be visible only if a field in SoftPro equals "STD". We picked a random field that we were not using and was able to get it to work with the following code:

return str(Order.Settings.PublishOnlineData) == 'STD'

However, I'd also like the other set to be hidden/invisible if that SoftPro field = "STD". The way I was trying to make this work is to set a visibility condition on BOTH document sets where one is...

return str(Order.Settings.PublishOnlineData) == 'STD'

and the other is...

return str(Order.Settings.PublishOnlineData) == 'null or blank'

Any ideas?
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Visibility based on blank field

Post by BobRichards »

You have come up with a good idea to handle the documents for your users. Below are a few basic building blocks for parsing user input safely.

Code: Select all

s = None
t = str(s)       # t = 'None'
t = bool(s)      # t == False

s = ""           # string of length zero
t = bool(s)      # t == False

s = "Hello"      # string containing one or more characters
t = bool(s)      # t == True
Example 1: Return True if user enters 'STD' in Related Orders

Code: Select all

return str(Order.Settings.PublishOnlineData) == 'STD' 
Is it possible to set a visibility condition based on if a field is blank?
Example 2: Enable document if user did NOT enter text in a field.

Code: Select all

return not bool(Order.Settings.PublishOnlineData)
Example 3: Enable document if user did NOT enter text in a field or entered 'STD'. In other words, set up the field so the default behavior is to treat the field as 'STD' unless the user enters a different code.

Code: Select all

return not bool(Order.Settings.PublishOnlineData) or str(Order.Settings.PublishOnlineData) == 'STD' 
Bob Richards, Senior Software Developer, SoftPro
RebeccahCTAC
Posts: 3
Joined: Sat Apr 27, 2019 3:14 pm

Re: Visibility based on blank field

Post by RebeccahCTAC »

Thank you so much!!! I will try this out!!
Post Reply