This How To describes how to set a how_to_set_up_and_use_udfs field based on selections or choices in the Pricing Form for a product. For example, we have a macro which generates lists when Orders have been shipped via UPS which are used to generate emails to our customers stating that their order has been shipped and the tracking number. We found that some customers do not want that notification when they are ordering for others, as might be the case with a Purchasing Department placing orders for other locations. We solved that problem with a TRUE/FALSE (Boolean) UDF which is set to TRUE or Yes if the contact does not want a notification. This page describes how to set that UDF.

The concept is to set a Transaction UDF when a Yes/No selection is made on the Pricing Form. In our Delivery Product Pricing Form where we specify the type of delivery - E.g. Commercial Carrier, UPS, Delivery, etc. we created a checkbox labelled “No Email Notification” with the Variable Name NoEmailNotification and a Transaction Boolean UDF named “No Email Notification.” Checking the box on the pricing form results in the UDF being set to TRUE. When we then run a Query for the contact list to use to obtain the names and email addresses for the Cyrious generated emails, we use the UDF setting to exclude contacts for which this UDF is set to TRUE.

You should test this carefully by checking and unchecking your Pricing Form checkbox and then saving your order. You can then view whether the UDF has been set properly by going to the UDF Tab in the Order Form or by right-clicking on the test order in your Order Explorer, Select Order Options, EDit UDFs. Any variation between the name of your UDF and the name you write in your code, will cause the code not to work.


  1. From the Setup/User Defined Field Setup go to the Transaction User Defined Fields. Select Add and Name your UDF. In this example it is named “No Email Notification”. (It is OK to have spaces in the name although the shorter the name, the easier you will find it is to work with the codes required to use the UDF). Be careful to select Checkbox as the Data Type. This is the dropdown menu directly under Descrption in the UDF Naming form. Next check to be sure that the checkbox “Show For Orders” is checked. If you wanted this UDF to be accessible in Estimates, Rrcurring Orders, etc, you would also check those boxes. Save your UDF.
  2. In the Variables Folder, create your variable. For this example, we have a folder for the variables used in the Delivery product and we created a new variable named “NoEmailNotification.” Here again it is essential to select “Yes/No Variable” as the Variable Type, again found in a dropdown list just under the name. Save your Variable.
  3. Open your Product and in the Variables Tab find and check the new variable. If the checkbox “Show Only Variables In Use” is checked you will have to uncheck that for the new variable to appear.
  4. Next click on the Pricing Tab, find the button at the bottom right which says “Advanced”. Click on that button. A form will pop up which has three Tabs - Minimums, Order Save Formulas, and Estimate Save Formulas. For this example, we set the UDF on Order actions, so we selected the Order Save Formulas tab.
  5. If you have followed these steps, you would now see four lines with a small blue arrow at the end of each: The first is “On Order Edit. Click on that blue arrow and a formula box will open. Beside the box is a button labelled “fx Builder”. Click on that to open Cyrious's formula checking and editing form, an absolutely invaluable aid for amateur code writers like us as it tells you if you have your code correct about 99% of the time. The formula we used is shown below. If you have different UDF and Variable Names, you would substitute those for the ones below: Enter the formula. Note that the function “settransactionudf” changes to green, the variable name “NoEmailNotification” changes to solid blue. This indicates that you have the correct syntax in the former case and that Cyrious found your variable in its library - I.e. you entered the name correctly. To further help you, if something is not right, it will probably be shown in burgundy and there will be a list of possible causes for your error in the lower left hand corner of the form. When correct, you will see the message “Formula OK. Cyrious does not tell you if you entered the UDF name incorrectly. The name must be an exact match to the UDF name. Even an extra space will cause the code to malfunction.
  6. If you want to have this UDF set whenever you do virtually anything with your Order, you would repeat this process for the other 4 options on the On Order Edit Tab. Similarly if you wanted to set the UDF when working with an Estimate, you would follow the same procuedures for the options in that tab. In our case we also entered the same code in the ON New Order or Line Item Created Box as well. You can now SAVE your product.
  7. Go to your pricing form for the product and add the checkbox which will trigger the UDF.
  8. Fire up the product in an Order and you should see your new checkbox. Check it and save your order. Click on the UDF tab and you should see that your new UDF is now checked.
settransactionudf("No Email Notification",NoEmailNotification)

Note that this UDF uses a trick Scott St.Cyr showed us. Since the NoEmailNotification is a boolean returning true or false, you can enter it directly into the function. If it has been checked, it will return a “1” or TRUE to the function. This is much cleaner than crafting a longer if statement such as the ones below which would also work.

IF NoEmailVerification
   Then SetTransactionUDF("No Email Notification",TRUE)


IF NoEmailNotification = TRUE
  Then SetTransactionUDF("No Email Notification",TRUE)

Contributor: Steve Gillispie, Acorn Sign Graphics

Date: 07/10/2009

Version: Control 4.30

You could leave a comment if you were logged in.