Page 1 of 1

How to check every seller

Posted: Wed Jun 07, 2023 5:13 pm
by svilla
Hi,
I'm new at this and I need some guidance. We want a document to populate if the seller has an AKA. What is the best way to look at every Seller to see if there is an AKA in that field?
I don't understand how to search every seller. I was looking at the code for loops but how do I count the number of sellers to make the loop work?

Re: How to check every seller

Posted: Tue Jun 13, 2023 3:21 pm
by BobRichards
In this script, we examine all the sellers until we either find one with an AKA value or run out of sellers. At the top of the Sellers loop, we move to the next seller if it is any type of organization. If it isn't (therefore, Male, Female, Joint), then we examine the Individual1 AKA property for a value. If so, we return True to allow the document to be visible. If Individual1 doesn't have an AKA property value and this is a joint seller, we check the Invidual2 AKA for a value. Ultimately if we never find an AKA value, we return False.

Code: Select all

# Test every seller in the order.
for seller in Order.Sellers:
	# Skip all organization contact types.
	if seller.BuyerSellerType >= seller.BuyerSellerType.Organization:
		continue

	# We must have an Individual1 property.
	aka = seller.Individual1.AKA
	if aka is not None and len(aka.strip()):
		# First seller individual has an AKA value.
		return True

	# Make sure we have an Individual2 before testing it.
	if seller.BuyerSellerType == seller.BuyerSellerType.Joint:
		aka = seller.Individual2.AKA
		if aka is not None and len(aka.strip()):
			# Second seller individual has an AKA value.
			return True
			
# No AKA found for sellers.
return False

Re: How to check every seller

Posted: Wed Jun 14, 2023 12:47 pm
by svilla
Thank you so much. That works great. Can you explain what "len(aka.strip())" does? Everything else I can follow.

Re: How to check every seller

Posted: Wed Jun 14, 2023 2:25 pm
by BobRichards
I want to determine if the AKA has printable characters in it - anything except spaces and tabs. The command "aka.strip()" removes all "whitespace" (non-printable characters like spaces and tabs from the front and end of the string).

Code: Select all

v = "   \t  hello  ".strip()  # v = "hello" (remove leading and trailing whitespace)
v = "goodbye".strip()         # v = "goodbye" (no change)
Lastly, I get the number of characters left in the string. In a Python if statement, if the value is not zero, it will be treated as True.

Re: How to check every seller

Posted: Wed Jun 14, 2023 2:45 pm
by svilla
That makes sense.

Following that same logic, I created the following and it's not working. I want to see a folder only if the seller is an organization. Do I need to specify what Organization type in order for this to work?

Code: Select all

# Test every seller in the order.
for seller in Order.Sellers:
	# Only show if seller is an organization.
	if seller.BuyerSellerType == seller.BuyerSellerType.Organization:
		return True

return False

Re: How to check every seller

Posted: Wed Jun 14, 2023 3:58 pm
by BobRichards
Really close. Under the covers, we assign a different numerical value to each possible BuyerSellerType. All organization types are 32 or greater. Minor correction to code below.

Code: Select all

# Test every seller in the order.
for seller in Order.Sellers:
	# Only show if seller is an organization.
	if seller.BuyerSellerType >= seller.BuyerSellerType.Organization:
		return True

return False

Re: How to check every seller

Posted: Thu Jun 15, 2023 12:34 pm
by svilla
Hi,
What is the best way to examine a custom field for each seller?

Code: Select all

# Test every seller in the order.
for seller in Order.Sellers:
        # Skip all organization contact types.
        if seller.BuyerSellerType >= seller.BuyerSellerType.Organization:
                continue

        # We must have an Individual1 POA name.
        POA1 = seller.POANameSeller1_SP##
        if POA1 is not None and len(POA1.strip()):
                # First seller individual has a POA value.
                return True

        # Make sure we have an Individual2 before testing it.
        if seller.BuyerSellerType == seller.BuyerSellerType.Joint:
                POA2 = seller.POANameSeller2_SP##
                if POA2 is not None and len(POA2.strip()):
                        # Second seller individual has a POA value.
                        return True
                        
# No POAs found for sellers.
return False


Re: How to check every seller

Posted: Wed Jun 21, 2023 11:30 am
by svilla
Hi,
I was reading an old post about custom fields and it mentions "IOrderItem interface." Is this something we need to be able to use custom fields to create ReadyDoc Visibility Conditions in SoftPro Select?

Re: How to check every seller

Posted: Tue Jun 27, 2023 1:30 pm
by vmrvichin
In a word no, there is no way use custom fields in determining the visibility for a document.

You are correct that in order to read/write to custom fields the IOrder interface is needed. This is usually brought into python code via an import. However the python code that executes to determine a document's visibility needs to execute quickly as it has the potential to be run against all documents. A result of this speed requirement it means that libraries are not able to be imported into the readydoc visibility python code.