[GIS] FME – How to add an attribute when schema definition is dynamic

dynamicfields-attributesfme

I have an FME workspace which reads a folder of MapInfo TAB files and writes them to a File Geodatabase. The reader and writers are both using dynamic schema as I need to run this workbench on multiple folders each containing several files.

What I would like to do is add an attribute to the feature class which contains the file path of the input TAB file. I have exposed the fme_dataset attribute on the reader and I have added it to the writer as well. That didn't work. I've also tried copying the fme_dataset attribute to another attribute called File_Path. That didn't work either.

I'm assuming that this isn't working because the schema definition is coming from the reader. But, why won't it work even when I expose the fme_dataset attribute?

I've looked at this similar post on FMEPedia, but I don't see how I can use a schema mapper for this purpose.

EDIT 07/01/2014

I thought this might be relevant as well, so I'll add the following:

I have created a separate attribute called FeatureClassName which is just the source file name which has been validated (removes non-word characters such as brackets). In the dynamic properties for the destination geodatabase, I have used a custom schema definition:

enter image description here

I am setting the Feature Type Name from that attribute:

enter image description here

The Schema definition is set to default (from Feature Type Name – above). Is it possible that this could be the reason I'm not able to add the attribute?

Best Answer

I'm going to disagree with Ken here (sorry Ken) and say this should work as you describe. If you add a new attribute to a dynamic schema it should get added to the output.

In fact, I've tried it myself and it seems to work, so I don't know why it isn't happening for you. I've posted my example to Dropbox for you to check out. It uses 2014 but the same technique should be good in earlier versions. The only difference to your scenario is that I'm using a fixed (not dynamic) reader.

When you say it doesn't work, is the attribute not added at all, or is it added but with an empty/missing value? I think that's an important distinction to help diagnose the problem. If the latter then check your schema field is large enough (it might be dropped rather than truncated) but I'm dubious that would be the cause.

If that fails to help I suggest talking to our support team.

Related Question