ArcGIS Pro 3.6 API Reference Guide
ArcGIS.Desktop.Reports Namespace / TemplateTokenFieldInfoValues Class
Members Example

In This Topic
    TemplateTokenFieldInfoValues Class
    In This Topic
    Represents the collection of TemplateTokenFieldInfoValues in a custom template.
    Syntax
    public class TemplateTokenFieldInfoValues 
    Public Class TemplateTokenFieldInfoValues 
    Example
    Create a report from a custom report template
    //Note: Run within QueuedTask.Run()
    await QueuedTask.Run(() =>
    {          
      // get the first map in the project
      MapProjectItem item = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(n => n.Name == "Cities");
      if (item == null)
        return;
    
      Map map = item.GetMap();
      if (map == null)
        return;
    
      Layer cityLayer = map.FindLayers("U.S. Cities")[0];
      if (cityLayer == null)
        return;
    
      // load template information
      var templatePath = System.IO.Path.Combine($@"{Project.Current.HomeFolderPath}\TemplateSimpleReportWithTokens.rptt");
      ReportCustomTemplateDefinition templateDef = ReportTemplateManager.GetCustomTemplateDefinition(templatePath);
      if (templateDef == null || templateDef.ReportTemplateDataSourceItems?.Count() < 1)
        return;
    
      // get template info of first data source (parent) and set its data source
      ReportCustomTemplateDataSourceInfo parentDataSourceInfo = templateDef.ReportTemplateDataSourceItems.ElementAt(0);
    
      parentDataSourceInfo.SetReportDataSource(cityLayer);
    
      TemplateTokenFieldInfoValues templateTokenFieldInfoValues = parentDataSourceInfo.TokenInfoValues;
    
      parentDataSourceInfo.DefinitionQuery = "STATE_NAME = 'Massachusetts'";
      templateTokenFieldInfoValues["[text-field-value-0]"] = "CITY_NAME";
      templateTokenFieldInfoValues["[text-field-name-0]"] = "City";
      templateTokenFieldInfoValues["[numeric-field-value-0]"] = "POP1990";
      templateTokenFieldInfoValues["[numeric-field-name-0]"] = "Population";
    
      if (templateDef.CanCreateReport())
      {
        // create the report
        report = ReportFactory.Instance.CreateReport("RelateSiblingsFromCode", templateDef);
      }
    });
    //UI thread
    if (report != null)
    {
      //open report
      await FrameworkApplication.Panes.CreateReportPaneAsync(report);
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Reports.TemplateTokenFieldInfoValues

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.6 or higher.
    See Also