Skip to main content
Solved

Generating a new primary key based on a concatenation of a string and a three digit increment

  • September 15, 2020
  • 2 replies
  • 48 views

I'm converting a batch of shp from one MCD to another. I can easily map 80% of the fields without any problem. But for the output MCD I need to generate a new primary key based on a concatenation of a string and a three digit increment. I've tried modifying the value (in the feature type dialog box) using the text editor, and 'string_'@Count() - this sort of works it produces 'string_1' etc but i need 'string_001' etc. Also, I already use Count() in another field which seems to confuse FME - This is probably very easy, but I'm new FME...

Best answer by redgeographics

You can add a Format function to it, like this:

string_@Format(%03d,@Count())

This will left-pad the count with zeroes to 3 characters.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

redgeographics
Celebrity
Forum|alt.badge.img+62
  • Celebrity
  • Best Answer
  • September 15, 2020

You can add a Format function to it, like this:

string_@Format(%03d,@Count())

This will left-pad the count with zeroes to 3 characters.


  • Author
  • September 15, 2020

You can add a Format function to it, like this:

string_@Format(%03d,@Count())

This will left-pad the count with zeroes to 3 characters.

Thanks that helped a lot!  

To summarize:

I started with  string_@Format(%03d,@Count()) - but I still had problems as I used multiple instances of Count() in the table. 

So in end I used a Counter before my file writer (to avoid using Count() multiple times. So in the end I  used this:

'string_@Format(%03d,@Value(_count))'