Skip to main content
Solved

Create attribute in loop with counter number in its name

  • November 7, 2018
  • 9 replies
  • 106 views

jeroen
Contributor
Forum|alt.badge.img+8

I'm trying to create multiple attributes during a loop depending on the amount X. If x = 3 the attributes created should be Foto_doc,Foto_doc2 and Foto_doc3.

I have a working flow with loop in the below example but the attribute creator does not work correctly with the @value(attribute_name) option. Is there something missing in this flow or is it not possible to use attribute values for naming attributes during a loop?

Best answer by jdh

Dynamically named attributes cannot be automatically exposed on the canvas and used by other transformers.

 

 

You can write them to a format if you use the SchemaSetter custom transformer and a writer set to Dynamic Schema Definition.

 

 

Personally I wouldn't use a loop at all, just a Cloner set to Max_Images, and build the attribute name from the _copynum attribute. This would also avoid the formatting issues of 2.0, 3.0, though that could be taken care of using the StringFormatter.
View original
Did this help you find an answer to your question?

9 replies

takashi
Influencer
  • November 7, 2018

The image and the workspace you have posted cannot be accessed for some reason. Could you please make sure that those have been uploaded correctly?


jeroen
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • November 7, 2018
takashi wrote:

The image and the workspace you have posted cannot be accessed for some reason. Could you please make sure that those have been uploaded correctly?

This should work now. Do not know what the problem was but i re-uploaded the file.


jeroen
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • November 7, 2018

Corrected the x = 2 into x = 3 to match the named outcome correctly.


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • November 7, 2018

Like Takashi I cannot access your workspace, but in situations where @Value(attribute_name) hasn't worked in the past (double check that it's a capital V), I've had success with FMEFunctionCaller using the @SupplyAttributes(attrName,attrValue) function.


jeroen
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • November 7, 2018
jdh wrote:

Like Takashi I cannot access your workspace, but in situations where @Value(attribute_name) hasn't worked in the past (double check that it's a capital V), I've had success with FMEFunctionCaller using the @SupplyAttributes(attrName,attrValue) function.

reuploaded the file. Also the image was missing now... hope it works now or it could be that the forum has a hard time.


ebygomm
Influencer
Forum|alt.badge.img+33
  • Influencer
  • November 7, 2018

It doesn't look like you are exposing the new attribute names?

 


jeroen
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • November 7, 2018
ebygomm wrote:

It doesn't look like you are exposing the new attribute names?

 

Thanks! Forgot that attributes could be hidden. The attribute exposer does not allow a value from attribute as input. But with manual inspection in the data inspector I can now see that the attributes are created but not showed in the endresult. Also the format is not what i would like.

 

Also: to solve the 2.0,3.0 I used @Evaluate(@round(@add(@Value(loopCounter),1),0))


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • Best Answer
  • November 7, 2018

Dynamically named attributes cannot be automatically exposed on the canvas and used by other transformers.

 

 

You can write them to a format if you use the SchemaSetter custom transformer and a writer set to Dynamic Schema Definition.

 

 

Personally I wouldn't use a loop at all, just a Cloner set to Max_Images, and build the attribute name from the _copynum attribute. This would also avoid the formatting issues of 2.0, 3.0, though that could be taken care of using the StringFormatter.

jeroen
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • November 7, 2018
jdh wrote:

Dynamically named attributes cannot be automatically exposed on the canvas and used by other transformers.

 

 

You can write them to a format if you use the SchemaSetter custom transformer and a writer set to Dynamic Schema Definition.

 

 

Personally I wouldn't use a loop at all, just a Cloner set to Max_Images, and build the attribute name from the _copynum attribute. This would also avoid the formatting issues of 2.0, 3.0, though that could be taken care of using the StringFormatter.

Schemasetter did the trick.

For the formatting: @Evaluate(@round(@add(@Value(loopCounter),1),0))


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings