SharePoint:编辑列表项时计算的列值消失。有任何想法吗?

时间:2021-07-30 08:56:50

I have a calculated column in a custom SharePoint 2007 list, with the following formula:

我在自定义SharePoint 2007列表中有一个计算列,使用以下公式:

=CONCATENATE("IR-",[ID],"-",LEFT(UPPER([Title]),25))

If an item is created in the list, everything is fine, however, when an item is updated the [ID] column is no longer in the calculated column for that item.

如果在列表中创建了一个项目,则一切正常,但是,当项目更新时,[ID]列不再位于该项目的计算列中。

So, on creation: "IR-40-TheTitleIsHere", but after edit, it is, "IR--TheTitleIsHere".

因此,在创作时:“IR-40-TheTitleIsHere”,但在编辑之后,它是“IR - TheTitleIsHere”。

Anyone have some insight on why this would be happening?

任何人都知道为什么会发生这种情况?

4 个解决方案

#1


I confirm the behavior mentioned above. Any Add/Edit will wipe out the [ID] portion. If you edit the column in the list and update the formula, it will update ALL list items to be correct (until you do an edit on the item).

我确认了上面提到的行为。任何添加/编辑都将清除[ID]部分。如果您编辑列表中的列并更新公式,它将更新所有列表项是正确的(直到您对项目进行编辑)。

I found this post that mentions the same problem.

我发现这篇帖子提到了同样的问题。

Sounds like the only solution would be to make a simple workflow using SharePoint Designer that would update a text field in your list.

听起来唯一的解决方案是使用SharePoint Designer创建一个简单的工作流程来更新列表中的文本字段。

#2


I had an issue similar a while back. Through other blogs and experts, I discovered that the [ID] column should not be used in a calculated column because it wreaks havoc and causes many errors. Sorry - remove the ID column and you should be fine.

我有一个类似的问题。通过其他博客和专家,我发现不应在计算列中使用[ID]列,因为它会造成严重破坏并导致许多错误。对不起 - 删除ID列,你应该没事。

#3


This question is a little old, but I had the same issue and found a solution for it. It is a pretty specific fix and won't help everyone -- it involves using javascript in a content editor web part to update the calculated field.

这个问题有点旧,但我遇到了同样的问题并找到了解决方案。这是一个非常具体的修复,并不会帮助每个人 - 它涉及在内容编辑器Web部件中使用javascript来更新计算字段。

This site -- http://blog.pathtosharepoint.com/2008/09/01/using-calculated-columns-to-write-html/ -- gives an example of how to use javascript in the same manner that I used it.. the important block of code is the first while loop. The point is to grab the out of box ID column from the list and update whatever calculated field needs the ID.

这个网站 - http://blog.pathtosharepoint.com/2008/09/01/using-calculated-columns-to-write-html/ - 给出了一个如何使用javascript的例子,就像我用它一样..重要的代码块是第一个while循环。重点是从列表中获取out out box ID列,并更新计算字段需要ID的任何内容。

In my case I had a URL in a calculated field that required the ID as a parameter.. of course that wouldn't work normally because you can't put the ID in a calculated field. What I did was I put "?ID=null" in the ID parameter of my calculated field's url, I then replaced that with the ID that was retrieved using javascript.. so whenever the page is loaded, the js kicks off and updates all of the URLs to have the correct ID.

在我的情况下,我在计算字段中有一个URL,需要将ID作为参数..当然,由于您无法将ID放在计算字段中,因此无法正常工作。我做的是在我的计算字段的url的ID参数中放入“?ID = null”,然后我将其替换为使用javascript检索的ID ..因此,无论何时加载页面,js都会启动并更新所有的URL具有正确的ID。

#4


I know this is very old but I couldn't find a newer version of the question anywhere else and the answer above from ferr solved the problem for me but isn't very clear so I thought I'd update it.

我知道这已经很老了,但是我找不到其他地方的问题的新版本,而ferr的上述答案为我解决了问题,但不是很清楚,所以我想我会更新它。

This assumes that you want to use the ID in the output HTML (for example within a link), I think this is fairly common.

这假设你想在输出HTML中使用ID(例如在链接中),我认为这是相当常见的。

Using the javascript from the pathtosharepoint link I added in the following to get the id with an if statement for safety:

使用来自pathtosharepoint链接的javascript,我在下面添加了以获取带有安全性的if语句的id:

if (HTMLregexp.test(CellContent)) {    //original pathtosharepoint line
   if (NodeSet[i].parentNode.getAttribute("iid")){
      var SPID = NodeSet[i].parentNode.getAttribute("iid").split(",")[1];
      CellContent = CellContent.replace("SPIDReplace", SPID)
   }
NodeSet[i].innerHTML = CellContent;   //original pathtosharepoint line

This is put in the while loop of the latest pathtosharepoint fix at time of writing. This works for me on SharePoint 2010. Note: Include the string "SPIDReplace" in your calculated column to get it replaced by the item ID.

这是在编写时最新的pathtosharepoint修复的while循环中。这适用于SharePoint 2010.注意:在计算列中包含字符串“SPIDReplace”,以便将其替换为项ID。

pathtosharepoint page: http://blog.pathtosharepoint.com/category/calculated-columns/ pathtosharepoint code: http://pathtosharepoint.com/Downloads

pathtosharepoint页面:http://blog.pathtosharepoint.com/category/calculated-columns/pathtosharepoint代码:http://pathtosharepoint.com/Downloads

#1


I confirm the behavior mentioned above. Any Add/Edit will wipe out the [ID] portion. If you edit the column in the list and update the formula, it will update ALL list items to be correct (until you do an edit on the item).

我确认了上面提到的行为。任何添加/编辑都将清除[ID]部分。如果您编辑列表中的列并更新公式,它将更新所有列表项是正确的(直到您对项目进行编辑)。

I found this post that mentions the same problem.

我发现这篇帖子提到了同样的问题。

Sounds like the only solution would be to make a simple workflow using SharePoint Designer that would update a text field in your list.

听起来唯一的解决方案是使用SharePoint Designer创建一个简单的工作流程来更新列表中的文本字段。

#2


I had an issue similar a while back. Through other blogs and experts, I discovered that the [ID] column should not be used in a calculated column because it wreaks havoc and causes many errors. Sorry - remove the ID column and you should be fine.

我有一个类似的问题。通过其他博客和专家,我发现不应在计算列中使用[ID]列,因为它会造成严重破坏并导致许多错误。对不起 - 删除ID列,你应该没事。

#3


This question is a little old, but I had the same issue and found a solution for it. It is a pretty specific fix and won't help everyone -- it involves using javascript in a content editor web part to update the calculated field.

这个问题有点旧,但我遇到了同样的问题并找到了解决方案。这是一个非常具体的修复,并不会帮助每个人 - 它涉及在内容编辑器Web部件中使用javascript来更新计算字段。

This site -- http://blog.pathtosharepoint.com/2008/09/01/using-calculated-columns-to-write-html/ -- gives an example of how to use javascript in the same manner that I used it.. the important block of code is the first while loop. The point is to grab the out of box ID column from the list and update whatever calculated field needs the ID.

这个网站 - http://blog.pathtosharepoint.com/2008/09/01/using-calculated-columns-to-write-html/ - 给出了一个如何使用javascript的例子,就像我用它一样..重要的代码块是第一个while循环。重点是从列表中获取out out box ID列,并更新计算字段需要ID的任何内容。

In my case I had a URL in a calculated field that required the ID as a parameter.. of course that wouldn't work normally because you can't put the ID in a calculated field. What I did was I put "?ID=null" in the ID parameter of my calculated field's url, I then replaced that with the ID that was retrieved using javascript.. so whenever the page is loaded, the js kicks off and updates all of the URLs to have the correct ID.

在我的情况下,我在计算字段中有一个URL,需要将ID作为参数..当然,由于您无法将ID放在计算字段中,因此无法正常工作。我做的是在我的计算字段的url的ID参数中放入“?ID = null”,然后我将其替换为使用javascript检索的ID ..因此,无论何时加载页面,js都会启动并更新所有的URL具有正确的ID。

#4


I know this is very old but I couldn't find a newer version of the question anywhere else and the answer above from ferr solved the problem for me but isn't very clear so I thought I'd update it.

我知道这已经很老了,但是我找不到其他地方的问题的新版本,而ferr的上述答案为我解决了问题,但不是很清楚,所以我想我会更新它。

This assumes that you want to use the ID in the output HTML (for example within a link), I think this is fairly common.

这假设你想在输出HTML中使用ID(例如在链接中),我认为这是相当常见的。

Using the javascript from the pathtosharepoint link I added in the following to get the id with an if statement for safety:

使用来自pathtosharepoint链接的javascript,我在下面添加了以获取带有安全性的if语句的id:

if (HTMLregexp.test(CellContent)) {    //original pathtosharepoint line
   if (NodeSet[i].parentNode.getAttribute("iid")){
      var SPID = NodeSet[i].parentNode.getAttribute("iid").split(",")[1];
      CellContent = CellContent.replace("SPIDReplace", SPID)
   }
NodeSet[i].innerHTML = CellContent;   //original pathtosharepoint line

This is put in the while loop of the latest pathtosharepoint fix at time of writing. This works for me on SharePoint 2010. Note: Include the string "SPIDReplace" in your calculated column to get it replaced by the item ID.

这是在编写时最新的pathtosharepoint修复的while循环中。这适用于SharePoint 2010.注意:在计算列中包含字符串“SPIDReplace”,以便将其替换为项ID。

pathtosharepoint page: http://blog.pathtosharepoint.com/category/calculated-columns/ pathtosharepoint code: http://pathtosharepoint.com/Downloads

pathtosharepoint页面:http://blog.pathtosharepoint.com/category/calculated-columns/pathtosharepoint代码:http://pathtosharepoint.com/Downloads