Describes how to create a macro that only runs after the first edit or recompute of an order.

Use cases:

  • When you are importing orders (via SQL Bridge) from a web system and need to run a macro on each order imported. However, you don't want to run the macro until after the order has been recomputed by the SSLIP in the background.

We will create a checkbox UDF called *First Edit Macro Run* that we will use to track if we need to trigger the macro. An indirect SQL macro that fires on *Order Edit* will then test to see if this value has been set. If not, it will run the macro actions, the last of which sets the UDF to checked.

As with all macros, there is the potential to degrade the system performance if not properly written.

  1. Create and name a new Transaction UDF called *First_Edit_Macro_Run* of type Checkbox (boolean). Have it apply to Orders only.
  2. Create a new Macro called *After Recompute Macro*.
  3. On the Trigger page, uncheck “Run in the background on Server” field
  4. Select the *On Edited* trigger and click on the radio button “An Indirect Change Event”
  5. Enter the SQL code
SELECT TH.ID, TH.ClassTypeID
FROM TransHeader TH
JOIN TransHeaderUserField U ON TH.ID = U.ID
WHERE TH.ID =
  AND COALESCE(U.[First_Edit_Macro_Run], 0) = 0  -- Note: 0 = unchecked, 1 = checked
  1. Add a UDF Macro Action to set the value of the *First_Edit_Macro_Run* UDF to checked.
  2. Add the Macro Actions to do the work you want

Contributor Cyrious

Date: 11/2017

Version: Control 6.0+

You could leave a comment if you were logged in.