SAP Knowledge Base Article - Public

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

Symptom

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?

 

Environment

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");
        ++flcnt;
        btnCount.Text = flcnt.ToString();
    }
    break;

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;
    }
    else
    {
        MessageBox.Show("Trigger Event - Error in Viewer: " + e.ToString());
    }
}

Resolution

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

Keywords

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

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio