Assign a variable with leading zero to a row in For Each

Hi All,

Hope had a great weekend.

I am facing a issue while assigning a variable with leading zeros to a column value in data table.
Below are the steps
in For Each Row in Dt1
For example: Var1 = 0068 ( reading from Database)
Assign row(“Column8”) = Var1

Var1 (68) is getting assigned to Column8 in DT1. I am not getting leading zeros.

I tried padding but its not working. Can you help me?

You have it as an integer value. That won’t keep the leading 0s because 0068 is really just 68 in terms of numbers. If you want to keep the leading 0s, make the column a string.

When I am reading the column value and assigning it to Var1(String), value is 0068. But when assigning Var1 to datatable cell, it’s written as 68.

the datatype of that destination column needs to be string too. Just update the column datatype in Datatable

If Var1 is string, it won’t let you assign 0068 to it. You could only assign “0068” to it, a string.

I am reading the data from a database where datatype is defined. I am not building datatable in my workflow.

How would I do this?

Why do you need leading 0s?

This field has some business function. Like Region Number, Market number

is it possible to add any character, symbol or combination of any text before the leading zero? That will prevent the conversion of that to absolute value? Just a thought…

If the column in the database is INT, it wouldn’t give you 0068. Somewhere you’re converting to INT and losing the leading 0s.

Try doing a Build Datatable first, and specify Column8 as string.