SAP Knowledge Base Article - Public

1927857 - How to change Group Options in RAS SDK based on a Date field


How to change Group Options in RAS SDK based on a Date field


Crystal Reports Developer for Visual Studio


Sample code on how to change the date condition grouping.


  • btnReportObjects is a text box to simply display the collection and results.
  • IsRpt is a flag used to set the viewer to ReportDocument or ReportClientDocument ( RAS ) object.

btnReportObjects.Text = "";
flcnt = 0;

foreach (CrystalDecisions.ReportAppServer.DataDefModel.Group resultField in rptClientDoc.DataDefController.DataDefinition.Groups)
    textBox1 = resultField.ConditionField.FormulaForm.ToString();
    btnReportObjects.Text += textBox1;
    btnReportObjects.AppendText(" 'End' \n");
    btnCount.Text = flcnt.ToString();

    CrystalDecisions.ReportAppServer.DataDefModel.Group oldGroup;
    CrystalDecisions.ReportAppServer.DataDefModel.Group newgroup;
    CrystalDecisions.ReportAppServer.DataDefModel.DateGroupOptions dgOpts = new CrystalDecisions.ReportAppServer.DataDefModel.DateGroupOptions();

    if (resultField.ConditionField.FormulaForm == "{Orders.Order Date}")
        dgOpts.DateCondition = CrystalDecisions.ReportAppServer.DataDefModel.CrDateConditionEnum.crDateConditionMonthly;

        oldGroup = rptClientDoc.DataDefController.DataDefinition.Groups[flcnt-1];
        newgroup = oldGroup.Clone(true);

        newgroup.Options = dgOpts;
        rptClientDoc.DataDefController.GroupController.Modify(oldGroup, newgroup);

        IsRpt = false;


KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem


SAP Crystal Reports XI R2 ; SAP Crystal Reports, developer version for Microsoft Visual Studio