SAP Knowledge Base Article - Public

1810170 - reportObject.RecordSelectionFormula returns no comments within the formula text


Getting the Record Selection formula in the .NET SDK does not return the Comments within the formula.


Crystal Reports Developer for Visual Studio


This is issue was tracked - ADAPT01498114 and is now resolved in CR for VS Service Pack 5

Create a simple windows project and use this code to get the record selection formula text:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportSource;

namespace WindowsFormsApplication1
    public partial class Form1 : Form
    public Form1()
    private void button1_Click(object sender, EventArgs e)
        CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new ReportDocument();

To use RAS to get the formula text:

using CrystalDecisions.ReportAppServer.ClientDoc;
using CrystalDecisions.ReportAppServer.Controllers;
using CrystalDecisions.ReportAppServer.ReportDefModel;
using CrystalDecisions.ReportAppServer.CommonControls;
using CrystalDecisions.ReportAppServer.CommLayer;
using CrystalDecisions.ReportAppServer.CommonObjectModel;
using CrystalDecisions.ReportAppServer.ObjectFactory;
using CrystalDecisions.ReportAppServer.DataDefModel;

// Record selection formula with comments included can only be retrieve via RAS using the FreeEditingText member
CrystalDecisions.ReportAppServer.DataDefModel.ISCRFilter myRecordSelectionWithComments; // = new CrystalDecisions.ReportAppServer.DataDefModel.;
myRecordSelectionWithComments = rptClientDoc.DataDefController.DataDefinition.RecordFilter;
if (myRecordSelectionWithComments.FreeEditingText != null)
    myRecordSelectionWithComments.FreeEditingText = rptClientDoc.DataDefController.RecordFilterController.GetFormulaText();
    btnRecordSelectionForm.Text = myRecordSelectionWithComments.FreeEditingText.ToString();
    btnRecordSelectionForm.Text = "No Record Selection formula";

NOTE: The Report Document (rpt.RecordSelectionFormula) returns the filtered, no comments, to the application and it can be modified by the QueryBuilder to be more SQL compliant. It may not look exactly like it does in CR Designer Show Query....

For example:

    {Table.Field} like "??A13*"
 or {Table.Field} like "??C13*"
 or {Table.Field} like "??D13*"

will convert to:

 (   (   (  {Table.Field} like "??A13*"
OR  {Table.Field} like "??C13*"  )
OR  {Table.Field} like "??D13*"  )



Crystal reports for Visual Studio, recordselectionformula, FreeEditingText , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem


SAP Crystal Reports, developer version for Microsoft Visual Studio