Page 1 of 1

Code Assistance

Posted: Thu Nov 09, 2023 8:11 am
by cklahr
Good morning,

I'm trying to add criteria to an automation snippet based on the below code snippet. I would like the system to check the Buyer contacts in the case of a purchase, and the lender contact in the case of a Refinance. If the contact name is "TBD" or "To be determined" the return should be false.

Thank you so much!

Code: Select all

from System import *
from SoftPro.ClientModel import *
from SoftPro.Select.Client import *
from SoftPro.OrderTracking.Client.Orders import *

def OrderContactsNotTBD():

	if Context.TransactionType = 'Purchase':
		return True
			
	for contact in Context.Buyers:
		if contact.Name == 'TBD' or contact.Name == 'To be determined':
			return False
		else:
			return True
		
OrderContactsNotTBD()

Re: Code Assistance

Posted: Thu Nov 09, 2023 5:26 pm
by PaulMcCullough
To compare TransactionType you need to use the values TransactionType.Purchase and TransactionType.Refinance instead of string values.

I think the following should do what you described.

Code: Select all

# For Purchase transactions this checks the Buyer names
# For Refinance transactions this checks the Lender names
# If at least one Contact has the name 'TBD' or 'To be determined' it returns False
# For everything else it returns True

def OrderContactsNotTBD():

	if Context.TransactionType == TransactionType.Purchase:
		for contact in Context.Buyers:
			if contact.Name == 'TBD' or contact.Name == 'To be determined':
				return False
				
	elif Context.TransactionType == TransactionType.Refinance:
		for contact in Context.Lenders:
			if contact.Name == 'TBD' or contact.Name == 'To be determined':
				return False

	return True

Re: Code Assistance

Posted: Fri Nov 10, 2023 6:03 am
by cklahr
Thank you very much!