Receiving Error when Object was not set/used
Posted: Mon Feb 04, 2019 9:02 pm
I am not new to SoftPro, but defiantly new to Python. While I try to find time to learn the various syntax of the Language and then determine what I can and cannot use in SoftPro, I still need to add a few basic filters.
Based on looking at a few examples and the information in this forum, I created a condition that checked the 1st Property State for a match. This all appeared to work as expected. However, as a way to allow me to see ALL Documents regardless of the Visibility Filter, I decided I was going to use the Order.Project field to place a Special Keyword in that would Override Any Standard Conditions and allow me to see the document regardless.
This too appeared to work, right up to the time that I tried to open the Documents Screen and the Test Order never had anything applied to the Order.Project field. I thought I used example logic to address this by adding the "hasattr()" to determine if the object existed, but this did not prevent the "in" statement from iterating the Project Field anyway. The error it returned states "Argument of type 'str' is not iterable."
Again the following works as expected when the project field has any value assign. Can someone please tell me what I am doing wrong or need to change. Thank you,
The Code I am using is as follows:
# 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 == 'UT') or (hasattr(Order,'Project') and '*ShowAllDocs' in Order.Project)
Based on looking at a few examples and the information in this forum, I created a condition that checked the 1st Property State for a match. This all appeared to work as expected. However, as a way to allow me to see ALL Documents regardless of the Visibility Filter, I decided I was going to use the Order.Project field to place a Special Keyword in that would Override Any Standard Conditions and allow me to see the document regardless.
This too appeared to work, right up to the time that I tried to open the Documents Screen and the Test Order never had anything applied to the Order.Project field. I thought I used example logic to address this by adding the "hasattr()" to determine if the object existed, but this did not prevent the "in" statement from iterating the Project Field anyway. The error it returned states "Argument of type 'str' is not iterable."
Again the following works as expected when the project field has any value assign. Can someone please tell me what I am doing wrong or need to change. Thank you,
The Code I am using is as follows:
# 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 == 'UT') or (hasattr(Order,'Project') and '*ShowAllDocs' in Order.Project)