Thank you for your answer on this. I did some additional reading in the SDK on 'Handling Disambiguities', and also read some related posts on the forum, including your very helpful post on how to work with lookup tables (
https://devforum.softprocorp.com/viewtopic.php?t=1475). While the lookup table in question does have 'Allow duplicate key field values' enabled, I don't believe this is a scenario that we are running into. The lookup code that I am trying to add in the automation code snippet is unique to that lookup table. This is how the lookup table in question is setup:
- RequirementsAndExceptionsLookupTable.png (144.94 KiB) Viewed 1153 times
To further test this out and try to find what is happening under the hood, I wrapped code being used to add the Requirement to the order in a Try/Except to see what type of exception we may be running into like this:
Code: Select all
if does_requirement_exist() == False:
try:
# Create instance of a requirement.
requirement = IOrder.CreateNew(Context, REQUIREMENT_CONTEXT)
requirement.Code = TARGET_LOOKUP_CODE
# Add new requirement to list of all requirements.
order_commitment_requirements = Context.Title.TitleInsuranceCalculations[0].Commitment.Requirements
order_commitment_requirements.Add(requirement)
except Exception as ex:
raise ValueError("Exception Type: " + type(ex).__name__)
When the code snippet executes, I do not run into an exception at all. It adds the Requirement to the order, however, the phrases used within the Requirement Text are not pulled from the order. An example from the Requirement specified in the lookup table is {{Order.ExistingLiens.Mortgagee}}; I suppose because the phrase is coded to look at the entire ExistingLiens collection, instead of one specific ExistingLien order field (e.g. Order.ExistingLiens[0].Mortgagee) it is not replacing any of the phrase codes when the requirement is added to the order. It is only when I try to manually add this particular requirement to the order do I get the "Reference to the single Existing Lien was encountered" prompt.
To try to find a work-around, I tried forcing the requirement.Text property from the code, using phrase codes pointing to specific ExistingLien objects like this:
Code: Select all
if does_requirement_exist() == False:
try:
# Create instance of a requirement.
requirement = IOrder.CreateNew(Context, REQUIREMENT_CONTEXT)
requirement.Code = TARGET_LOOKUP_CODE
requirement.Text = "BEGIN TEST: Satisfaction and release of that certain judgment(s) in favor of {{Order.ExistingLiens[0].Mortgagee}} against {{Order.ExistingLiens[0].Mortgagor}} recorded in Public Records Book {{Order.ExistingLiens[0].Recording.BookNumber}} at Page {{Order.ExistingLiens[0].Recording.PageNumber}}, in the amount of ${{Order.ExistingLiens[0].OriginalPrincipalAmount}}, plus interest and cost...END TEST"
# Add new requirement to list of all requirements.
order_commitment_requirements = Context.Title.TitleInsuranceCalculations[0].Commitment.Requirements
order_commitment_requirements.Add(requirement)
except Exception as ex:
raise ValueError("Exception Type: " + type(ex).__name__)
When the code executes, no exception is encountered, and it adds the Requirement text, but does not interpolate any of the field codes used in the Requirement text with the proper values entered on the order.
Ultimately, I will need to find a way to programmatically add multiple Requirements to an order, with each requirement pulling text from a specific ExistingLien object, roughly like this:
Code: Select all
# Get Existing Lien count matching criteria
matching_liens = len([str(lien.InstrumentType.Description) for lien in Context.ExistingLiens if str(lien.InstrumentType.Description) == INSTRUMENT_TYPE])
# Add new requirements to list of all requirements.
order_commitment_requirements = Context.Title.TitleInsuranceCalculations[0].Commitment.Requirements
for lien in matching_liens:
order_commitment_requirements.Add(requirement) # Not sure how to specify which ExistingLien to reference here, as seen when manually adding the requirement to the order
Given the use of non-specific phrase codes used in Requirement text like {{Order.ExistingLiens[0].Mortgagor}}, is what I am trying to do feasible? In looking around the Field Code Browser, I did find a "Phrases" property associated with the Requirements object, but I was unsuccessful in trying to work with this either through automation snippets nor via Custom Order Rules to see if I could maybe see what their values looked like via args.RaiseInformation()
Thank you again for your time and info!