Skip to main content

Hi,

I've tried to wrap some specific functionality in a custom tranformer in Workbench, and have defined a parameter (in the custom transformer) to be the name of the new attribute containing the output I'm calculating.

I'm creating the value into a temp local attribute (for a reason, I'm deleting it at the end), but cannot apparently rename or copy this temp attribute to an attribute with the configured name ?

Cheers

 

Lars
test-rename-in-custom-transformer.fmw

You can indeed rename an attribute in a custom transformer based on a published parameter, e.g. if your parameter is called "NewName":

What complicates it slightly, though, is that the attribute name "NewName" isn't automatically exposed (made visible) in the Workbench editor, you will have to do that manually using e.g. an AttributeExposer after calling the custom transformer.


My usual (secret 😉 trick is to use a BulkAttributeRenamer. This exposes the specified attribute name automatically.


My usual (secret 😉 trick is to use a BulkAttributeRenamer. This exposes the specified attribute name automatically.

Nice trick!


You can indeed rename an attribute in a custom transformer based on a published parameter, e.g. if your parameter is called "NewName":

What complicates it slightly, though, is that the attribute name "NewName" isn't automatically exposed (made visible) in the Workbench editor, you will have to do that manually using e.g. an AttributeExposer after calling the custom transformer.

Hi David,

No, that doesn't work, and I did try this before I posted.

I get the error: Undefined macro `NEW_NAME' dereferenced in file `C:\\Users\\lin\\Documents\\My FME Workspaces\\wb-xlate-1467288075556_12320'

Cheers

 

Lars

My usual (secret 😉 trick is to use a BulkAttributeRenamer. This exposes the specified attribute name automatically.

Hi Takashi,

This doesn't work either.

Please note that I want to rename the attribute _inside_ the custom transformer, not outside.

Have either of you tried to run the workspace I attached with the changes ?

Cheers

 

Lars

Hi Takashi,

This doesn't work either.

Please note that I want to rename the attribute _inside_ the custom transformer, not outside.

Have either of you tried to run the workspace I attached with the changes ?

Cheers

 

Lars

please check this demo: test-rename-in-custom-transformer-2.fmw


Hi David,

No, that doesn't work, and I did try this before I posted.

I get the error: Undefined macro `NEW_NAME' dereferenced in file `C:\\Users\\lin\\Documents\\My FME Workspaces\\wb-xlate-1467288075556_12320'

Cheers

 

Lars

Worked perfectly when I tested it using FME 2016.1. The attribute gets renamed inside the custom transformer.

But I think Takashi's suggestion was even better than mine, so you might want to look at that first.


Hi Takashi,

That works !

Which is strange, because I did exactly what you described and did here, and it didn't work for me !?!

Ah well, my motto in these cases is: You shouldn't strive to understand why something doesn't work, just rejoyce when it does :-D

And so I shall. Thanks again.

Cheers

 

Lars

Hi Takashi,

That works !

Which is strange, because I did exactly what you described and did here, and it didn't work for me !?!

Ah well, my motto in these cases is: You shouldn't strive to understand why something doesn't work, just rejoyce when it does :-D

And so I shall. Thanks again.

Cheers

 

Lars

Ah, found my mistake. You used ".+", I entered ".*". Need stronger glasses :-)


Hi Takashi,

That works !

Which is strange, because I did exactly what you described and did here, and it didn't work for me !?!

Ah well, my motto in these cases is: You shouldn't strive to understand why something doesn't work, just rejoyce when it does :-D

And so I shall. Thanks again.

Cheers

 

Lars

Good to hear it works!

I also thought ".*" could work theoretically, but it doesn't work in fact. In my observation, available regex for the trick are:

  • .+
  • ^.+
  • .+$
  • ^.+$
  • ^.*
  • ^.*$

These two regex were unavailable:

  • .* (this will not rename the attribute)
  • .*$ (surprisingly, this will concatenate two specified string)

I don't know the reason why the last two expressions don't work...


Reply