public static void ModifyReport(Report report, string reportName, FeatureLayer featureLayer)
        {
            #region Rename Report
            //Note: Call within QueuedTask.Run()
            ReportProjectItem reportProjItem = Project.Current.GetItems <ReportProjectItem>().FirstOrDefault(item => item.Name.Equals(reportName));
            reportProjItem.GetReport().SetName("RenamedReport");
            #endregion

            #region Modify the Report datasource
            //Note: Call within QueuedTask.Run()
            //Remove Groups
            // The fields in the datasource used for the report
            var listFields = new List <string> {
                "STATE_NAME"
            };
            report.RemoveGroups(listFields);

            //Add Group
            report.AddGroup("STATE_NAME", true, true, "");

            //Modify the Definition Query
            var defQuery = "STATE_NAME LIKE 'C%'";
            report.SetDefinitionQuery(defQuery);
            #endregion

            #region Modify the report Page
            //Note: Call within QueuedTask.Run()
            var cimReportPage = new CIMPage
            {
                Height          = 12,
                StretchElements = false,
                Width           = 6.5,
                ShowRulers      = true,
                ShowGuides      = true,
                Margin          = new CIMMargin {
                    Bottom = 1, Left = 1, Right = 1, Top = 1
                },
                Units = LinearUnit.Inches
            };
            report.SetPage(cimReportPage);
            //Change only the report's page height
            report.SetPageHeight(12);
            #endregion
        }