Add character by a script

Hello,

I have a field in string, and in this field, i have different numbers (example : 0032345643).

I want to add "0" at the beginning when the number have only 9 characters, and add "00" at the beginning when the number have only 8 characters.

It's possible in dev tools ?
have you an example of script for that ?

Thanks !

Hi @Fred59,

It is possible by transforming data with scripted fields:

Your script may look like

doc['your_field'].value.toString().length() == 9 ? "0"+doc['your_field'].value : "00"+doc['your_field'].value 

Regards, Dzmitry

hello
perfect, thank, i will try that monday at work :slight_smile:

Hello,

Possible to make this modification in dev tools for modifi the actual field et don't create a new field by scripted field ?

Because many visualisations use actually this field.

nobody ? :frowning:

Up please, i don't find anything :frowning:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.