SAP Knowledge Base Article - Public

1957609 - Expose resultField.UseCount in FormulaFields collections in .NET SDK


For reports that may use a custom UFL and that UFL does not exist on the local PC is there a way to determine what that formula of UFL is?



Crystal Reports Developer for Visual Studio

Reproducing the Issue

Case example:

By exposing resultField.UseCount in FormulaFields collections you can determine if a Custom UFL is used in the report but does not exist on the local PC.

case "Formula Fields":
    btnReportObjects.Text = "";
    int flcnt = 0;
    foreach (FormulaField resultField in rptClientDoc.DataDefController.DataDefinition.FormulaFields)
        textBox1 = resultField.LongName.ToString();
        btnReportObjects.Text += textBox1;
        btnReportObjects.AppendText(" : Used: " + resultField.UseCount.ToString() + " times'End' \n");
        btnCount.Text = flcnt.ToString();

By adding a viewer event handler the missing UFL can be detected:

private void crystalReportViewer1_Error(object source, ExceptionEventArgs e)
    string eError = "";
    eError = e.Exception.Message.ToString();
    if (eError.Substring(0, 61) == @"The remaining text does not appear to be part of the formula.")
        MessageBox.Show("Possible missing UFL or actual error in formula");
        e.Handled = true;
        MessageBox.Show("Trigger Event - Error in Viewer: " + e.ToString());


Expose resultField.UseCount in FormulaFields collections in all SDK platforms so it can be used publicly


usecount, Crystal Reprots for Visual Studio, field collection, UFL not found, UFL, User function Library , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , Problem


SAP Crystal Reports, developer version for Microsoft Visual Studio