Validating circular references of a formula

Optiva provides a built-in database function FSCRONFORMULA, which identifies circular dependencies within formula structures.

To add the script and validate a workflow script:

  1. Define a query in Optiva that passes the formula ID to the FSCRONFORMULA function. Below is a sample query using the code C_FINDCIRCLES:
    SELECT F.FORMULA_CODE, F.VERSION, DESCRIPTION
    FROM FSCRONFORMULA([%1]) R
    INNER JOIN FSFORMULA F ON R.FORMULA_ID = F.FORMULA_ID
    ORDER BY 1, 2
    
  2. Create a workflow script that calls this query and displays the results, for example:
    MessageList("Check for circular references")
    Dim dt As DataTable = TableLookupEx("C_FINDCIRCLES", "mytable", ObjProperty("FORMULAID"))
    if not dt Is Nothing AndAlso dt.Rows.Count > 0 then
        MessageList("Circular Reference nesting found:")
        for Each dr As DataRow In dt.Rows
            MessageList(dr(0), "\", dr(1), ": ", dr(2))
        Next
    Else
        MessageList("No circular references found")
    End If
    
  3. Click Launch Workflow option in the Formula form.
    Note: You must fix the circular references to launch workflow successfully.