An explanation and guide to setting how_to_set_up_and_use_udfs based on the contents or state of Transaction Variables.

UDF's can be set as True or False (0 or 1) or populated with Dates or strings based on the state of variables in a Product. However, this must be done in the Advanced Tab found under the Pricing Tab in either the Order or Estimates Save Tab formula builder. For example, in the example below, UDFs are set to true or false if booleans are checked in the Product's Pricing Form such as “Blind Ship” or “No Email”.

It is always a good idea to use CFL's default settings for UDFs which are entered by following the UDF name with a comma, and a value which is what you want the UDF formula to return if one is not found. For example, SetTransactionUDF(“OrderNO”,0) will result in a 0 rather than an error message if the UDF is not found. The coding for UDF's requires such precision in the placement of quotation marks, the exact replication of the UDF name, etc. that mistakes are easy to make. Test all code carefully before creating any dependency on it. This is easy to do with the Debugger. Go to a transaction, select a line item, and enter CTL-ALT_SPACEBAR. Paste your code into the Debugger and execute. If modifying a UDF, look in the Transactions UDFs tab and check if the UDF has changed as you expected.

  1. The screen shot below shows the steps taken to open the Advanced Tab found in the Product's Pricing Tab. There ae a number of options available depending on when you want the formula to activate – when the Order is Edited, Deleted, Voided, or Created. Note also that you can set different formulas for different Pricing Plans. There is a separate tab with the same options for an Estimate. In the example below note that the selection “On New Order… is in red. For this code we have entered the same code in both places to capture all possible conditions short of voiding the order where the Order may be changed.

  1. We recommend always opening thehow-to_make_coding_easier_with_the_formula_builder to enter the code. That provides a partial check that there are no errors in the code, although it can not know if the UDF is not spelled correctly. Note that you can Declare temporary variables and have the full use of cfl_reference code to set up the conditions for the result. The code shown above uses the Case Statement to examine 7 Boolean variables from the Pricing Form and populate a Shipping UDF which then passes information to the UPS WorldShip program about the type of shipment selected in the Pricing Form.

Contributor: Steve Gillispie, Acorn Sign Graphics

Date: 06/09/2010

Version: Control 4.3

You could leave a comment if you were logged in.