Auto Increment enabled in data table but only takes zero for every transaction

Hi Everyone,

I am building data table dynamically and want serial number for each row.

I have declared a column as SNo in Builddata table activity and declared the same and run the application

In excel every row is saved as with the serial number 0. If I give SNo value as 1 then it saves 1 in each row. Please find the screenshots

image

image

image

image

Thanks,
Ulaga

Hi @Boopathi

Could you share a bit about your method of adding new rows? I believe the autoincrement will only work if you add your row like this:
image
image

Thank you. I have added like this. Do I need to modify now?

image

I am not sure or don’t know exact syntax to add in DataRow

I am not sure and will have to check, but my first guess was that the auto increment will only work if you do not assign a value to it but rather leave it up to UiPath. This is why dt.NewRow works - it creates an empty row in the Data Table and then the autoincrement works without an issue.

You could first create a row with Add Data Row activity like in my previous screenshot and then assign values to the columns with a few Assign activities.

I just checked and you have to simply use Nothing as your SNo column value :slight_smile:

image

Will give the output (when looped over and over):
image

1 Like

@Boopathi After Add Data Row empty Sno and check it

Hi @loginerror. I gave first value as nothing but again 0 is getting added pls check if any need to correct anything. Please find the screenshots below

SNo column created and same created in the variable section and gave the first column value as nothing.

image

image

@Boopathi is it possible to attach your workflow

Hi @indra I gave SNo as β€œβ€ in the array row but still 0 only gets added in the excel for each transaction

Could you give this example a look and see if it helps?
Randomprocess.zip (2.5 KB)

Hi @loginerror. Thank you. I worked separately by including add data row in a loop and it produces a result as you given. However, my bot completes one transaction by using an hot key like ctrl+o and saves exception log in excel file (there is no loop to add data row) and again another user initiates a bot using same hot key and the bot runs. so everytime the bot runs it is considered like frehs transaction only 0 saves in SNo in exception log file. Is there any workaround for this?.

Please find the screenshot

image

If I got you correctly (and the screenshot), you want to add a row to the Excel file. Because you need a Data Table to do that, you do these steps:

  1. Build Data Table
  2. Add Data Row to that NEW data table
  3. Append Range

If so, the Index will always show 0 because there is nothing in the Data Table :slight_smile: - only the 1 row you have just added.

This can be solved by first making sure the file already exists, and if not:

  • use current workflow to create it
    If yes:
  • load the Excel file into the Data Table variable instead on Add Row to that Data Table.

I hope it makes sense :slight_smile:

@loginerror. Thank you and what you have said is correct. I need to make changes as you suggested. I will try it out.

Hi @loginerror. I have attached xaml could you please correct it how to load excel file into data table variable. I am using generate data table but not getting expected one. Main.xaml (1.2 KB)

exceptionlog.xlsx (8.3 KB)

The xaml file is empty for me, could you check it is the correctly uploaded?

@loginerror. I am sorry. not sure what went wrong. I have reattached. Main.xaml (10.1 KB)

@Boopathi

See attachment :slight_smile:
AutoIncrementProject.zip (3.5 KB)

There was something I missed in my original answer - the Read Range activity does not automatically assume that the first column should increment in value, thus we cannot simply add our new row to the Data Table it automatically creates.

The solution is to Build our Data Table also for the situation where the file exists and then fill it in with data read from Excel.

I hope the xaml file is clear :slight_smile: I cleaned it up a bit and commented a bit too.

2 Likes

Hi @loginerror. Thank you very much and i am going to implement this in my project by removing append range. I am new to uipath and forum helps me a lot.