Expressions

With the new functionality, UI column name can be used in expressions to do a lookup for a database table and field. The following are examples of lookup:

u"\~carrier_lpn.tracking_nbr"

where carrier_lpn is the database table and the tracking_nbr is the field separated by a .

Two lookups separated by a space as a string:

u"\~order_header.custom_long_text_3
        \~order_header.custom_long_text_4"

The following is an example of writing an if condition statement: Note the "" around the field lookup so that the result is treated as a string.

"Not Manifested!" if "\~carrier_lpn.tracking_nbr " == "" else "\~carrier_lpn.tracking_nbr"

Slicing and length expression example: Note this example starts from the 3rd position to the end of the string, extracting that portion of the string.

"\~order_header.order_nbr "[slice(2,len( "\~order_header.order_nbr "))]

Split expression with accessing the first element example:

split( "\~order_header.custom_long_text_3 ",
        ";")[0]

Complex split expression example:

split("\~order_header.custom_long_text_3", ";")[0] + "\n" +
        split("\~order_header.custom_long_text_3", ";")[1] + " " +
        split("\~order_header.custom_long_text_3", ";")[2] + " " +
        split("\~order_header.custom_long_text_3", ";")[3] + "\n" +
        split("\~order_header.custom_long_text_3", ";")[4] + ", " +
        split("\~order_header.custom_long_text_3", ";")[5] + " " +
        split("\~order_header.custom_long_text_3", ";")[6]

The following is an example of a more complex inline if split expression:

str("(No \~order_header.customer_number)") if
        len(split("\~order_header.custom_field_5", ";")) < 12 else str("(No " +
        split("\~order_header.custom_field_5", ";")[11] + "\~order_header.customer_number" +
        ")")

New Expressions Supported

u"str(5) + str(5)"

get_country_name("AD")

get_country_code("UNITED STATES")

get_us_state_name("GA")

get_us_state_code("GEORGIA")

"strftime(\~order_header.mod_ts, "%m/%Y")"

The following is an example of an expression for container weight:

str(int((10*\~container.weight)-0.5)+1).zfill(7) + "A"

A container weight of 65.46 would result in 0000655A. Zfill does the padding for the resulting string and int((10*\~container.weight)-0.5)+1 rounds the number up and moves up one decimal place.

To test your expression on your own computer, you will need simple eval python. You can look at more examples on the following website:

https://pypi.python.org/pypi/simpleeval

Passing Function Parameters

Example Of Date Time Formatting:

%d/%m/%Y - %H:%M:%S

See Python strftime Directives for more details on Date Time Formatting.

Blind Label Mappings:

"container.container_nbr"

"order_header.destination_company.code"

"order_header.dest_facility.code"

"company.code"

dict_get(get_obj(),
        "order_header.destination_company.code")
str(dict_get(get_obj(), "company.code"))[slice(5,len(dict_get(get_obj(),
        "company.code")))]