Sharepoint 2013/2016 计算列停止计算

Sharepoint 2013/2016 Calculated Column stops calculating

我在 SharePoint On-Premises 中有一个计算列,它显示截止日期前的天数,它完美地工作了一天左右然后停止计算,但是如果我转到列表设置并单击该列并单击确定然后它再次计算?

有没有人遇到过类似的问题。我在 2013 年和 2016 年都遇到过这个问题,但在几周内转移到 2016 年,仍然是同样的问题。

我试过“”空白和“”空白所以不确定这是否导致了问题??

是不是公式有问题?

公式如下:

 =IF(ISBLANK([Due Date])," ",
IF(ISERROR(DATEDIF(NOW(),[Due Date],"d"))," ",DATEDIF(NOW(),[Due Date],"d")))

,其中包括依赖于当前日期的那些。

The values in SharePoint columns--even in calculated columns--are stored in SharePoint's underlying SQL Server database.

The calculations in calculated columns are not performed upon page load; rather, they are recalculated only whenever an item is changed (in which case the formula is recalculated just for that specific item), or whenever the column formula is changed (in which case the formula is recalculated for all items).

如果您需要显示随时间变化的动态值,您有几种选择。

客户端呈现

考虑使用 客户端呈现,这样您就可以使用 JavaScript 动态确定列表视图中记录的显示方式。此 JavaScript 在页面加载时运行,因此它可以比计算列更好地处理当前的时间相关值。

要使用客户端呈现,您需要创建一个 JavaScript 文件来控制视图的显示方式。您将该文件上传到 SharePoint 上的某个位置,人们至少可以对其进行读取访问,然后编辑您想要以不同方式显示的列表视图 Web 部件,并将其“JSLink”属性 设置为指向您的 JavaScript 文件.

查看 this answer 以获取使用 JSLink 文件欺骗动态日期字段的示例。

Microsoft 还提供了一些文档 here 但我认为他们做的工作比必要的多(在 Visual Studio 中为他们的示例创建了一个全新的列表定义项目,而不是仅仅创建一个 JSLink JavaScript 现有列表的文件)。

其他选项

上面链接的旧问题中提到了一些其他选项:

  1. Conditional Formatting: You can apply conditional formatting to highlight records that meet certain criteria. This can be done using SharePoint Designer or HTML/JavaScript.

  2. Filtered List views: Since views of lists are queried and generated in real time, you can use volatile values in list view filters. You can set up a list view web part that only shows items where Created is equal to [Today]. Since you can place multiple list view web parts on one page, you could have one section for today's items, and another web part for all the other items, giving you a visual separation.

  3. A workflow, timer job, or scheduled task: You can use a repeating process to set the value of a normal (non-calculated) column on a daily basis. You need to be careful with this approach to ensure good performance; you wouldn't want it to query for and update every item in the list if the list has surpassed the list view threshold, for example.

要扩展筛选列表视图选项,您可以拥有一个仅显示在特定天数内到期的项目的视图。例如,您可以通过筛选 Due Date 字段小于 [Today]+7Due Date 大于或等于 [Today] 的字段来显示 7 天内到期的所有项目。您还可以对视图进行排序,以将截止日期较早的项目显示在靠近顶部的位置。