<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Setting Index of an Attribute in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/setting-index-of-an-attribute/m-p/1236837#M9135</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/628386"&gt;@Meroni&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;You cannot modify the order of table attributes at the database level, but you can change them at the LAYERS level at any time.&lt;/P&gt;&lt;P&gt;To modify the attributes' order at the database level, we recommend to clone and reorder the original attributes into a new table as&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private static void CloneAndReorderFields(Geodatabase geodatabase, TableDefinition oldTableDefinition)
{
  SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
  
  // Old table description
  TableDescription oldTableDescription = new TableDescription(oldTableDefinition);
  
  // Old table's field descriptions
  List&amp;lt;FieldDescription&amp;gt; oldTableFieldDescriptions = new List&amp;lt;FieldDescription&amp;gt;(oldTableDescription.FieldDescriptions);

  // Reordered field descriptions
  List&amp;lt;FieldDescription&amp;gt; reorderedFieldDescriptions = new List&amp;lt;FieldDescription&amp;gt;()
  {
	// Change the order of attribute fields from index 2, 1, 0 (old) to 0, 1, 2 in the new table 
	oldTableFieldDescriptions[2], oldTableFieldDescriptions[1], oldTableFieldDescriptions[0]  	
  };

  // Creating a new reordered table
  TableDescription reorderdTableDescription = new TableDescription($"{oldTableDefinition.GetName()}_Reorder", reorderedFieldDescriptions);
  
  // Build the new table
  schemaBuilder.Create(reorderdTableDescription);
  bool buildStatus= schemaBuilder.Build();
}&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 01 Dec 2022 16:02:11 GMT</pubDate>
    <dc:creator>Aashis</dc:creator>
    <dc:date>2022-12-01T16:02:11Z</dc:date>
    <item>
      <title>Setting Index of an Attribute</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/setting-index-of-an-attribute/m-p/1236737#M9131</link>
      <description>&lt;P&gt;Hi, is it possible to change the order of attributes in a table? If not, how would I go about cloning a table into a new one, but with reordered attributes?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 09:35:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/setting-index-of-an-attribute/m-p/1236737#M9131</guid>
      <dc:creator>Meroni</dc:creator>
      <dc:date>2022-12-01T09:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Index of an Attribute</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/setting-index-of-an-attribute/m-p/1236837#M9135</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/628386"&gt;@Meroni&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;You cannot modify the order of table attributes at the database level, but you can change them at the LAYERS level at any time.&lt;/P&gt;&lt;P&gt;To modify the attributes' order at the database level, we recommend to clone and reorder the original attributes into a new table as&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private static void CloneAndReorderFields(Geodatabase geodatabase, TableDefinition oldTableDefinition)
{
  SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
  
  // Old table description
  TableDescription oldTableDescription = new TableDescription(oldTableDefinition);
  
  // Old table's field descriptions
  List&amp;lt;FieldDescription&amp;gt; oldTableFieldDescriptions = new List&amp;lt;FieldDescription&amp;gt;(oldTableDescription.FieldDescriptions);

  // Reordered field descriptions
  List&amp;lt;FieldDescription&amp;gt; reorderedFieldDescriptions = new List&amp;lt;FieldDescription&amp;gt;()
  {
	// Change the order of attribute fields from index 2, 1, 0 (old) to 0, 1, 2 in the new table 
	oldTableFieldDescriptions[2], oldTableFieldDescriptions[1], oldTableFieldDescriptions[0]  	
  };

  // Creating a new reordered table
  TableDescription reorderdTableDescription = new TableDescription($"{oldTableDefinition.GetName()}_Reorder", reorderedFieldDescriptions);
  
  // Build the new table
  schemaBuilder.Create(reorderdTableDescription);
  bool buildStatus= schemaBuilder.Build();
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 01 Dec 2022 16:02:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/setting-index-of-an-attribute/m-p/1236837#M9135</guid>
      <dc:creator>Aashis</dc:creator>
      <dc:date>2022-12-01T16:02:11Z</dc:date>
    </item>
  </channel>
</rss>

