Jun 23 2023 07:22 AM - edited Jun 23 2023 09:22 AM
Hello, I'm trying to create a column in the sharepoint. The column that I'm trying to create is New Code column. So I want to add TT at the beginning and then the value that in column Name and then 000 and then the sequence. But I want the sequence to change once the name change as it shows in the exmple below.
Name | New Code |
William | TTWilliam0001 |
William | TTWilliam0002 |
William | TTWilliam0003 |
William | TTWilliam0004 |
William | TTWilliam0005 |
Thomas | TTThomas0001 |
Thomas | TTThomas0002 |
Thomas | TTThomas0003 |
Thomas | TTThomas0004 |
Thomas | TTThomas0005 |
Daniel | TTDaniel0001 |
Daniel | TTDaniel0002 |
Daniel | TTDaniel0003 |
Jun 23 2023 08:12 AM
Hi @Totosmsm ,
SharePoint is not build like that. Using a calculated column you can only access data from the current row.
In this case you need to create a flow.
Go to powerautomate.com and create a new automated cloud flow with the trigger "When a new item
is created or modified (SharePoint)"
Set "Site Adress" and "List name"
Add a condition with "New Code is not equal to <empty>"
In the "if yes" branch, add a SharePoint "Get Items" action with the condition
"Name eq '<Name from "When an item is created or modified">'"
TT@{items('Apply_to_each')?['Name']}000@{length(outputs('Get_items')?['body/value'])}
Add a SharePoint "Update Item" action and set the ID field to the value of ID from the "When an item is created or modified" Trigger and set the "New Code Field" to
You complete flow should look like this
Save it.
This flow will run everytime the item is saved.
If will check if the "New Code" field is empty. Then it will count all items with the corresponding name and will update the "New Code" field to your pattern
Best Regards,
Sven