Page 1 of 1

Endorsement Custom Field

Posted: Thu Nov 19, 2020 12:38 pm
by KWoods
I am trying to set the value of a custom field and need some assistance.

The field is on the Title>Endorsements page.

The Field code is {{Order.Title.Endorsements.ExceptionNumbers287_FNF#}}
Can you give a code snippet of how I can access this value?
CustomField.jpg
CustomField.jpg (197.7 KiB) Viewed 2604 times
Thank you

Re: Endorsement Custom Field

Posted: Thu Nov 19, 2020 2:38 pm
by BobRichards
We have to treat the hash symbol specially since it is not a valid character in the body of Python code - but it is a valid character for a Python function. (Yes - it's strange.) What we do is create a temporary name for the function where we put our code then rename it later.

For instance, I have a custom field on the endorsement context that is a string with the field code of "FCExample##". I create a dummy function name (Endorsement_FCExample) and put my value code in it. At the bottom of the code body, I rename it to the correct name so Select can find it when it runs. Please note that the word "name" at the bottom has two underscores at the beginning and end. Use the same strategy for Validate, ReadOnly, etc. aspect rules.

Code: Select all

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

def Endorsement_FCExample(args):
	args.Value = 'Hello'
	
Endorsement_FCExample.__name__ = 'Endorsement_FCExample##_Value'

Re: Endorsement Custom Field

Posted: Thu Nov 19, 2020 3:36 pm
by KWoods
I'm sorry, I should have been more clear. I am using C#. I am not as familiar with python.

Re: Endorsement Custom Field

Posted: Thu Nov 19, 2020 3:47 pm
by BobRichards
No worries. The "Custom Order Rules" forum is reserved for a type of Select rules written in Python. In the future, use the "Integration Development" forum or use a forum under it if it is a better fit. That way I know which language you want the answer in. :)

For C#, the field code is the property name. Below are two examples of getting values from the endorsement object.

Code: Select all

IOrderItem endorsement = ...;
string d = (string)endorsement.GetProperty("CDFChargeDescription");
string fc = (string)endorsement.GetProperty("ExceptionNumbers287_FNF#");