cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Microsoft
Microsoft

Update Sharepoint List Column with a Auto Incremented Value to each Item

I have little different situation here , where my sharepoint list items gets erased and refreshed on a daily basis. due to which the first record/item in the list , would have some random number as ID but not 1.

 

( note : i read some where that sharepoint would not reset the ID numbers , unless you re-create the list . since i am erasing and updating the same List, every time i erase and add a new record, that record would start with the last erased record ID + 1)

 

Since i need a ID column that starts the first record with ID value 1 , incremented by 1.

 

So i have added a new column (uniqueid ; integer) , for which i want to populate numbers from 1 to N , once sharepoint list is refreshed. 

 

Three Questions :

1) Is there any way sharepoint list ID can be reset when list is erased (not deleted) , so that first record would always have ID value =1 . If this is a limitation .. no issue.. ignore this question.

 

2. How to fix the error below, so that i can insert auto incremented value to each reach record in the uniqueID column that starts with value 1.

 

3. I want to call this 'update-uniqueID-column' flow (child) as soon the 'erase-refresh-sharepoint-list' flow (parent). How can i call the child once parent execution is complete ?

How to fix this 

Below is the form is created with a variable and increment variable . But i am getting the below error.

 

Child Flow :

dsab81_1-1600477249320.png

 

Child Flow Error :

dsab81_2-1600477280059.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Hi @dsab81 

1. SharePoint List-ID field cannot be reset to start with 1 unless the list is deleted and re-created.

2. The below error is because the flow is trying to create an item with the value that exists in the list for another item. Since the field is set to capture unique values, the value of the field should be unique and cannot be repeated. In your case, the field 'UniqueID' properties is set to maintain unique values. So consider if an item with the value of 'abcd' already exists, you cannot add another item with the same value 'abcd' for 'UniqueID' field.

 

Hope it helps, please like it or mark it as a solution if it resolves your clarification or issue
-Sudharsan K...

Hope it helps, please like it or mark it as a solution if it resolves your clarification or issue
-Sudharsan K...

View solution in original post

3 REPLIES 3
Super User
Super User

Hi @dsab81 

1. SharePoint List-ID field cannot be reset to start with 1 unless the list is deleted and re-created.

2. The below error is because the flow is trying to create an item with the value that exists in the list for another item. Since the field is set to capture unique values, the value of the field should be unique and cannot be repeated. In your case, the field 'UniqueID' properties is set to maintain unique values. So consider if an item with the value of 'abcd' already exists, you cannot add another item with the same value 'abcd' for 'UniqueID' field.

 

Hope it helps, please like it or mark it as a solution if it resolves your clarification or issue
-Sudharsan K...

Hope it helps, please like it or mark it as a solution if it resolves your clarification or issue
-Sudharsan K...

View solution in original post

Thanks.  How can I insert auto incremented values in the column with unique values, starting with value 1 .

Hi @dsab81 

You have used the 'Update Item' action in the 'Apply to each' and then setting the 'Unique ID' field value. Why don't you set the 'Unique ID' when you are creating the item. I am not sure how you are creating the items, if it is via flow, then you can set the uniqueid while creating the items.

If you still prefer to update the uniqueid on the update item, then you have to check the list whether there are any items using the uniqueid, and then based on the return value, you have to check whether the length of the items returned is greater than 0 or not, if it is not then update the value, if it is then you have to increament the value and then do the checking cycle again. 

The other option is to declare an array and get all the uniqueid's from the list before the 'Apply to each' action so that you can compare the array and do the update.

 

Hope it helps, please like it or mark it as a solution if it resolves your clarification or issue
-Sudharsan K...

Hope it helps, please like it or mark it as a solution if it resolves your clarification or issue
-Sudharsan K...

Helpful resources

Announcements
PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (3,592)