Creating column

Copper Contributor

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.

 

NameNew 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
1 Reply

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"

SvenSieverding_0-1687532053212.png

Add a condition with "New Code is not equal to <empty>" 

SvenSieverding_1-1687532113994.png

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">'"

SvenSieverding_2-1687532327125.png

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



SvenSieverding_3-1687532816577.png


You complete flow should look like this

SvenSieverding_4-1687532850600.png

 

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

SvenSieverding_5-1687533013249.png

Best Regards,
Sven