CardExchange Solutions Documentation

Producer Help - Designer Properties - Functions

In the Functions tab, it is possible to define global variables, functions and references that can be used in Python scripts.


IMPORTANT! Functions are supported in our Business edition only!

By using well-defined functions, the scripts in the Content and Expressions tabs can be kept consistent. It would not be possible to use much of the power of Python in scripts, if you could not define functions.

A function definition should strictly follow the Python syntax as described in the Python documentation. An example of a function is:

def IsValid(s):
  if s == 'OK':
    return 'Transparent'
  else:
    return 'Red'

This function returns either ‘Transparent’ or ‘Red’ depending on the value of the input parameter s.


Global variables can be defined in the Function tab with a simple assignment statement. Once defined, they can be used in functions and scripts. For example, instead of the above function, we could make the following definition, with the global variable warningColor:


warningColor = 'Red'

def IsValid(s):
  if s == 'OK':
    return 'Transparent'
  else:
    return warningColor


Finally, the Functions tab can be used to reference Python modules, in order to use them in functions and scripts. The following example imports the .NET Framework System module and uses it to re-format a date string:


import System

def FormatDate(s):
  d = System.DateTime.Parse(s)
  return d.ToString('dd-MM-yyyy')


The designer uses IronPython for executing scripts. IronPython is the .NET Framework implementation of the well-known Python scripting language. For extensive documentation on IronPython, please visit www.ironpython.org.