Solved

FME Desktop 2020: How to permanently reorder the fields of attribute table of geodatabase feature class?

  • 6 November 2020
  • 22 replies
  • 140 views

Badge +5

FME Desktop 2020: How to permanently reorder the fields of attribute table of geodatabase feature class?

 

In the screenshot below, I wanted to permanently move F3 to be to the right of F1. Which tool can be of help on this?

 

Clip_314

icon

Best answer by david_r 11 November 2020, 10:14

View original

22 replies

Userlevel 6
Badge +33

I don't think you can change the order in the FeatureClass, other then re-arrange and then rewrite the table. But in Workbench you can use the AttributeManager for another order. Actually, this is the only thing I use the AttributeManager for.

Badge +5

I performed the “attributemanager” tool but appears that the output feature class don’t have the fields ordered.

 

What could be the issue here?

 

Clip_316Clip_317Clip_318 

 

 

 

 

 

Userlevel 6
Badge +33

I performed the “attributemanager” tool but appears that the output feature class don’t have the fields ordered.

 

What could be the issue here?

 

Clip_316Clip_317Clip_318 

 

 

 

 

 

Ah I misunderstood. In the Writer, tab User Attributes, change that order should do it.

Badge +5

Ah I misunderstood. In the Writer, tab User Attributes, change that order should do it.

not sure why this appears not to work. the output still keeps the fields as they are in the input!

what might be the issue?

 

Clip_320

Userlevel 6
Badge +33

Ah I misunderstood. In the Writer, tab User Attributes, change that order should do it.

Try not dynamic but manual. Dynamic tries to reproduce the source schema, and that is what you want to change.

Badge +5

Ah I misunderstood. In the Writer, tab User Attributes, change that order should do it.

Even with manual option, the fields of the attribute table don’t respect the attribute definition.

 

What could be the issue here?

 

Clip_321

Userlevel 5

Ah I misunderstood. In the Writer, tab User Attributes, change that order should do it.

Are you re-creating the target feature class, or simply truncating the table? You'll need to drop and recreate the table for changes in attribute order.

Badge +5

Ah I misunderstood. In the Writer, tab User Attributes, change that order should do it.

Thanks David

 

It appears that reordering the fields with the attributemanager tool fails as per the screenshot below.

 

What could be the issue here?

 

 

Clip_334

Userlevel 5

Ah I misunderstood. In the Writer, tab User Attributes, change that order should do it.

Two things:

  1. Make sure the attribute order is correct in the output feature type, not in the AttributeManager (too many if's and but's)
  2. Check the written attribute order using ArcGIS, not FME Inspector.
Badge +3

Further, the FME Visual Preview is not the Geodatabase Schema. This does not "show" you what the resulting Geodatabase Schema and Field Order is, that is instead set by the Writer. The FME Visual Preview/Inspector only shows the FME Workspace Schema.

 

What has happened here, is the Writer was first created without the AttributeManager first being inserted to re-order the fields. The Writer intialised its Schema in the field order that existing in the Workspace at the time and replicated the field order in the Reader. Changing the order in AttributeManager does nothing once a Writer Schema Definition has already been manually set by itself, instead the Writer Schema needs to be changed within the Writer settings to change Field Order.

 

For most use cases, I manually set the output Schema within the Writer to get the desired field order, field types and field names (and I also drop ObjectID. This is a Geodatabase System controlled field and cannot be written out to a GDB), with the exception of when I use Dynamic Reader/Writers but even those the Writer settings can override the FME Workspace Schema.

 

 

Badge +5

Ah I misunderstood. In the Writer, tab User Attributes, change that order should do it.

 

The issue persists to exist. The output doesn’t respect the fields order set in the attributemanager anyway.

 

All what I did is that the F3 field is moved to be before F1. The output feature class keeps the original order and doesn’t respect what is set in attributemanager

 

What could be the issue?

 

The data and workbench are attached

 

Clip_337 

Clip_338 

 

 

 

 

Badge +5

Thanks bwn

 

Doesn’t this mean that there is no chance to order the fields the way we like anyway?

Userlevel 5

Ah I misunderstood. In the Writer, tab User Attributes, change that order should do it.

The issue is that the target feature class already exists with the "wrong" attribute order. And since you haven't told FME to re-create the feature class, there are no changes made to the table structure, only the content is added. You will have to configure the table handing to drop and create for the schema to be updated:

tablehandling

Badge +5

Hi David,

 

Even with “drop and create” option, the order is not repected.

 

Has it worked with you?

 

Clip_339Clip_340 

 

Userlevel 6
Badge +33

Hi David,

 

Even with “drop and create” option, the order is not repected.

 

Has it worked with you?

 

Clip_339Clip_340 

 

Please stop using the AttributeManager for attribute order outside the workspace.

You need to change the order in the Writer, not in the AttributeManager.

Only use the AttributeManager if you want to change the order in the visual preview / inspector.

I wish I never mentioned the AttributeManager :P

Badge +5

Thanks nielsgerrits.

 

Finally it works with “manual” option as per the screenshot below.

 

Thanks for the patience

 

Clip_341 

Clip_342 

 

Userlevel 5

Hi David,

 

Even with “drop and create” option, the order is not repected.

 

Has it worked with you?

 

Clip_339Clip_340 

 

If you want to preserve the attribute order set in the AttributeManager, you'll have to configure the output feature type to use automatic attribute definition. If you set it to manual, the order defined in the output feature type overrides the AttributeManager.

2020-11-11 10_12_27-Feature Type

Badge +5

If you want to preserve the attribute order set in the AttributeManager, you'll have to configure the output feature type to use automatic attribute definition. If you set it to manual, the order defined in the output feature type overrides the AttributeManager.

2020-11-11 10_12_27-Feature Type

Thanks David. It works like a charm with this option too!

 

Very much appreciated

 

Clip_343 

Clip_344 

 

Badge +3

Thanks bwn

 

Doesn’t this mean that there is no chance to order the fields the way we like anyway?

FME can absolutely Write the Schema in the Field order required, however it depends on the use case:

1. The default, and easiest way to understand, is to change the "Attribute Definition" within the Writer to "Manual", and to change the Writer Mode to "Drop and Create" (or set the Writer to Overwrite the entire Geodatabase in the Writer Parameters). In this configuration, it doesn't matter what the Workspace does with the FME Schema, the Writer will override the output to a Fixed Schema that you have set within the Writer and so this guarantees a consistent Schema output no matter how you change the Workspace design. As @david_r​ points out though, if it is an existing Feature Class that is being written to, to change the order of fields requires either for the Feature Class to be Dropped (Deleted) in the Writer Mode, or alternatively in ArcCatalog to change the field order there. FME can't change the order of fields on an existing GDB feature class, so it needs to be dropped and written from scratch or changed within ArcGIS

2. The Writer Schema can be, at least temporarily, "reset" by changing the Writer Attribute Definition to "Automatic", which will reset the Writer Schema to match the FME Workspace Schema and change the Writer to have the Field Names and Field Order currently existing in the Workspace, and is useful for sometimes "reorganising" a Manual Schema by changing the setting briefly to Automatic and then back to Manual.

3. The hardest to understand and get used to, but the most powerful and flexible, is to set the Writer Attribute Definition to "Dynamic" which can be a mixture of a Dynamic and Fixed Schemas. Dynamic writing is a separate topic. For the moment, I would instead just use Manual and learn that mode first.

Badge +3

Please stop using the AttributeManager for attribute order outside the workspace.

You need to change the order in the Writer, not in the AttributeManager.

Only use the AttributeManager if you want to change the order in the visual preview / inspector.

I wish I never mentioned the AttributeManager :P

Yes, AttributeManager does not change the Writer Schema, it only changes the FME Workspace Schema. The Writer controls the GDB Written Schema, not AttributeManager.

 

AttributeManager CAN be used to proxy set the Writer Schema, but only when the Writer has been set to automatically/dynamically adjust its Writer Schema to match the FME Workspace Schema. 🙂

Badge +5

Thank you very much guys for the help. Your input is very useful

Best

Jamal

Badge +10

Ah I misunderstood. In the Writer, tab User Attributes, change that order should do it.

you have to set the output to manual. See attached gdb output.

Reply