Retrieving the value of a custom field

Questions about and code samples for automation process code snippets within Select.
Post Reply
codvisor
Posts: 6
Joined: Wed Nov 09, 2022 12:52 pm

Retrieving the value of a custom field

Post by codvisor »

Hi,

I have a custom field in the Order context which is a List of values type.
How can I get the value of this custom field via code snippet?
The code snippet is triggered when a file is saved / closed.

Many thanks !!
BobRichards
Posts: 1271
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Retrieving the value of a custom field

Post by BobRichards »

A drop-down custom field is a list of strings. For this example, let's say you are using this drop-down custom field on the Order context.
DropDownListExample.png
DropDownListExample.png (18 KiB) Viewed 326 times
First, we then create an automation snippet that runs every time an order is saved. Use the code below for the "Then" clause.

Code: Select all

from System import *
from SoftPro.OrderTracking.Client.Orders import *
# Write to event viewer
import System.Diagnostics as SD

# Context is Order.
def MyFunc():
	s = 'Context: %s' % str(Context)
	s += '\nOrder.DemoDropDown## = ' 
	s += IOrderItem.GetProperty(Context,'DemoDropDown##')
	SD.Trace.TraceWarning(s)

MyFunc()
Finally, we create a new order, set the new field (Order.DemoDropDown##) to "Item #3" then save the order. When the code runs, this message will be written to the Event Viewer.

Code: Select all

Context: Order XAT22002270
Order.DemoDropDown## = Item #3
Bob Richards, Senior Software Developer, SoftPro
codvisor
Posts: 6
Joined: Wed Nov 09, 2022 12:52 pm

Re: Retrieving the value of a custom field

Post by codvisor »

Perfect!
Many thanks
Post Reply