A workaround would be to rename your attribute to a known string (constant) at the start of the workspace, then renaming it to the value of your published parameter just before the writer.
David
@jryan and @david_r, Using AttributeRenamer or AttributeManager to rename an attribute to a value represented in a published parameter results in error. See selection-157.png. Please kindly advise how you did this.
Hi
Which version of FME are you using? I just tested FME 2016.1 and it works fine.
FME 2015.1.3.1 didn't manage it, however, but you could accomplish the same using a PythonCaller:
import fmeobjects
def FeatureProcessor(feature):
newName = FME_MacroValues/'pEvent_Route_ID']
value = feature.getAttribute('_pEvent_Route_ID')
feature.setAttribute(newName, value)
feature.removeAttribute('_pEvent_Route_ID')
David
Hi
Which version of FME are you using? I just tested FME 2016.1 and it works fine.
FME 2015.1.3.1 didn't manage it, however, but you could accomplish the same using a PythonCaller:
import fmeobjects
def FeatureProcessor(feature):
newName = FME_MacroValues/'pEvent_Route_ID']
value = feature.getAttribute('_pEvent_Route_ID')
feature.setAttribute(newName, value)
feature.removeAttribute('_pEvent_Route_ID')
David
Thank you very much for your help! Yes, it works in 2016.1 even though the UI does not provide a way to pick a parameter for the "Output Attribute." For older versions, I could use follow your python code!
The only way I've successfully output a parameterized attribute name in a custom transformer is to use a StringConcatenator with the New Attribute set to the Custom transformer parameter and the string expression set to the temporary attribute (that you want to rename). Follow that by an AttributeRemover to remove the temp attribute, and you end up with a custom transformer (CT) that behaves like any other transformer in regards to propagating attributes.
ie if you set the AttributeName parameter on the CT to "abc' than the rest of the workspace will have access to the abc attribute. If you set it to a workspace parameter then the rest of the workspace will have access to $(UserAttr) which at runtime will be whatever the user specified.
@jdh, thanks for the work around!
Just communicated with Safe tech support on the case, FYI -
This issue has been previously reported as problem report PR# 58160 - Custom Transformer Framework: Undefined macro dereferenced in file. Development has reported that the issue is the published parameter looking reference in the output port or attribute name name. Because of how custom transformers work, that published parameter is prefixed so doesn't really exist at runtime. Hence the error. This attribute / output port was returned because the port name was automatically generated based on their condition.
@jryan and @david_r, Using AttributeRenamer or AttributeManager to rename an attribute to a value represented in a published parameter results in error. See selection-157.png. Please kindly advise how you did this.
Why not surf FME Hub? I have several solutions published in the FME Hub for a long time. e.g.
- 2DVectorCalculator (X/Y Component Attribute)
- AttributeConcatenator (Destination Attribute)
- AttributeListExploder (List Name)
- ListElementExtractor (Destination Attributes)
- ListStatisticsCalculator (Prefix of Statistics Attributes)
etc.
Note: Some of them are experimental. Depending on FME version, may not work as expected.
@jryan and @david_r, Using AttributeRenamer or AttributeManager to rename an attribute to a value represented in a published parameter results in error. See selection-157.png. Please kindly advise how you did this.
Does someone already have a simple solution to this?
How to set the attribute name to published parameter value in FME 2019.1 ?
How to set the attribute name to published parameter value in FME 2019.1 ?
Hi @fikusas,
Thanks for your question! I noticed that this original question was posted a very long time ago, would you be open to posting a new question and linking to this one for context? This will make your new question more visible for the Community to provide more helpful suggestions.
Hi @fikusas,
Thanks for your question! I noticed that this original question was posted a very long time ago, would you be open to posting a new question and linking to this one for context? This will make your new question more visible for the Community to provide more helpful suggestions.
Yeah, I'll post it as a new question. Thanks for suggestion.
The only way I've successfully output a parameterized attribute name in a custom transformer is to use a StringConcatenator with the New Attribute set to the Custom transformer parameter and the string expression set to the temporary attribute (that you want to rename). Follow that by an AttributeRemover to remove the temp attribute, and you end up with a custom transformer (CT) that behaves like any other transformer in regards to propagating attributes.
ie if you set the AttributeName parameter on the CT to "abc' than the rest of the workspace will have access to the abc attribute. If you set it to a workspace parameter then the rest of the workspace will have access to $(UserAttr) which at runtime will be whatever the user specified.
This was very helpful @jdh . Thanks! I was able to rename the attribute to a parameter by using the StringConcatenator as it would allow me to pull in the value of the existing attribute while at the same time renaming the field to the parameter.
- Expression Results: Create New Attribute
- New Attribute: siteid
- StringExpresstion: @Value($(siteid_parameter))