ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.CIM Namespace / CIMTableField Class / Name Property
Example

In This Topic
    Name Property (CIMTableField)
    In This Topic
    Gets or sets the field name and unique identifier.
    Syntax
    public string Name {get; set;}
    Public Property Name As String
    Example
    Create report
    //Note: Call within QueuedTask.Run()
    //The fields in the datasource used for the report
    //This uses a US Cities dataset
    var listFields = new List<CIMReportField> {
              //Grouping should be the first field
              new CIMReportField{Name = "STATE_NAME", FieldOrder = 0, Group = true, SortInfo = FieldSortInfo.Desc}, //Group cities using STATES
              new CIMReportField{Name = "CITY_NAME", FieldOrder = 1},
              new CIMReportField{Name = "POP1990", FieldOrder = 2, },
          };
    //Definition query to use for the data source
    var defQuery = "STATE_NAME LIKE 'C%'";
    //Define the Datasource
    var reportDataSource = new ReportDataSource(featureLayer, defQuery, listFields);
    //The CIMPage defintion - page size, units, etc
    var cimReportPage = new CIMPage
    {
      Height = 11,
      StretchElements = false,
      Width = 6.5,
      ShowRulers = true,
      ShowGuides = true,
      Margin = new CIMMargin { Bottom = 1, Left = 1, Right = 1, Top = 1 },
      Units = LinearUnit.Inches
    };
    
    //Report template
    var reportTemplates = await ReportTemplateManager.GetTemplatesAsync();
    var reportTemplate = reportTemplates.Where(r => r.Name == "Attribute List with Grouping").First();
    
    //Report Styling
    var reportStyles = await ReportStylingManager.GetStylingsAsync();
    var reportStyle = reportStyles.Where(s => s == "Cool Tones").First();
    
    //Field Statistics
    var fieldStatisticsList = new List<ReportFieldStatistic> {
              new ReportFieldStatistic{ Field = "POP1990", Statistic = FieldStatisticsFlag.Sum}
              //Note: NoStatistics option for FieldStatisticsFlag is not supported.
          };
    var report = ReportFactory.Instance.CreateReport("USAReport", reportDataSource, cimReportPage, fieldStatisticsList, reportTemplate, reportStyle);
    Create a new field in the report
    //This is the gap between two fields
    double fieldIncrement = 0.9388875113593206276389;
    //On the QueuedTask
    //New field to add.
    var newReportField = new CIMReportField
    {
      Name = "POP1990",
      FieldOrder = 2,
    };
    //Get the "ReportSection element"                
    var mainReportSection = report.Elements.OfType<ReportSection>().FirstOrDefault();
    if (mainReportSection == null) return;
    
    //Get the "ReportDetails" within the ReportSectionElement. ReportDetails is where "fields" are.
    var reportDetailsSection = mainReportSection?.Elements.OfType<ReportDetails>().FirstOrDefault();
    if (reportDetailsSection == null) return;
    
    //Within ReportDetails find the envelope that encloses a field.
    //We get the first CIMParagraphTextGraphic in the collection so that we can add the new field next to it.                    
    var lastFieldGraphic = reportDetailsSection.Elements.FirstOrDefault((r) =>
    {
      var gr = r as GraphicElement;
      if (gr == null) return false;
      return (gr.GetGraphic() is CIMParagraphTextGraphic ? true : false);
    });
    //Get the Envelope of the last field
    var graphicBounds = lastFieldGraphic.GetBounds();
    
    //Min and Max values of the envelope
    var xMinOfFieldEnvelope = graphicBounds.XMin;
    var yMinOfFieldEnvelope = graphicBounds.YMin;
    
    var xMaxOfFieldEnvelope = graphicBounds.XMax;
    var YMaxOfFieldEnvelope = graphicBounds.YMax;
    //create the new Envelope to be offset from the existing field
    //At 2.x
    //MapPoint newMinPoint = MapPointBuilder.CreateMapPoint(xMinOfFieldEnvelope + fieldIncrement, yMinOfFieldEnvelope);
    //MapPoint newMaxPoint = MapPointBuilder.CreateMapPoint(xMaxOfFieldEnvelope + fieldIncrement, YMaxOfFieldEnvelope);
    //Envelope newFieldEnvelope = EnvelopeBuilder.CreateEnvelope(newMinPoint, newMaxPoint);
    
    MapPoint newMinPoint = MapPointBuilderEx.CreateMapPoint(xMinOfFieldEnvelope + fieldIncrement, yMinOfFieldEnvelope);
    MapPoint newMaxPoint = MapPointBuilderEx.CreateMapPoint(xMaxOfFieldEnvelope + fieldIncrement, YMaxOfFieldEnvelope);
    Envelope newFieldEnvelope = EnvelopeBuilderEx.CreateEnvelope(newMinPoint, newMaxPoint);
    
    //Create field
    GraphicElement fieldGraphic = ReportElementFactory.Instance.CreateFieldValueTextElement(reportDetailsSection, newFieldEnvelope, newReportField);
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also