ID field is not updated automatically

I have a field that uses a computed column type to reference an ID field. This is mainly: Name & ID. For instance. Name01, Name02, Name03, etc.

However, when I add new rows to the sharepoint, this column is not updated automatically, and I need to manually click in the field to update it.

Is there any way around this? Thanks

+4
source share
2 answers

I also saw this behavior, and this is not obvious, because when you first create a column (and every time you edit a column), everything looks great and dandy.

I found that I can work around this problem using the SharePoint Designer workflow. The workflow updates the plain text field to store the identifier value, and then the computed columns can refer to this text field instead of the actual identifier field.

Stages:

  • Add a text box to my list called ItemID
  • In SharePoint Designer, add a new workflow to the list and set it to run when items are added or updated.
  • Add a workflow action to save the item id to a string (Build Dynamic String)
  • Add a workflow action to set the ItemID field to the value that I saved in the previous step (Set the field in the current item).
  • Add a workflow action to update the current item (update list item)

Then I just need to reference [ItemID] in my computed columns instead of [ID], and it works like a charm.

One drawback is that users end up seeing the ItemID field in the New and Edit forms if you haven’t done something to hide it.

If you have more time on hand and want to avoid sending out a list of workflow history, you can follow the same workaround in the event handler.

+1
source

This is by design.

The calculated columns cannot contain the ID field in their expression. The reason for this is that sharepoint retains the value of the result of the calculated field when creating / updating. After creating the item, the identifier does not exist yet. Therefore, he has nothing to populate. However, as soon as the value is updated, you will see that the identifier is full and is now available.

0
source

Source: https://habr.com/ru/post/1343946/


All Articles