Page 1 of 1

Visibility based on blank field

Posted: Wed May 01, 2019 5:12 pm
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?

Re: Visibility based on blank field

Posted: Thu May 02, 2019 1:40 pm
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' 

Re: Visibility based on blank field

Posted: Fri May 17, 2019 10:01 am
by RebeccahCTAC
Thank you so much!!! I will try this out!!