SharePoint 2013/2016计算列停止计算 [英] Sharepoint 2013/2016 Calculated Column stops calculating

查看:101
本文介绍了SharePoint 2013/2016计算列停止计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a calculated column in SharePoint On-Premises that shows the number of days till a due date which works perfectly for a day or so then stops calculating, but if I go to the list settings and click the column and click ok then it calculates again?

任何人都遇到过与此类似的问题.我在2013年和2013年都遇到过这个问题,但在几周后移至2016年,仍然是同一问题.

Has anyone experienced an issue similar to this. I had this issue in both 2013 but within a few weeks moved to 2016 and still the same issue.

我已经尝试过将"设为空白,也将"设为空,所以不确定是否会导致此问题?

I've tried " " blank and also "" empty so not sure if that is causing the issue??

公式有问题吗?

这是公式:

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

推荐答案

Calculated columns cannot contain volatile functions, which includes those that depend on the current date.

SharePoint列中的值(甚至是计算列中的值)都存储在SharePoint的基础SQL Server数据库中.

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).

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

If you need to show a dynamic value that changes with the passage of time, you have a few alternatives.

考虑使用客户端呈现,它使您可以使用JavaScript动态确定列表视图中记录的显示方式.该JavaScript在页面加载时运行,因此它可以处理当前与时间相关的值,远胜于计算列.

Consider using client-side rendering which lets you use JavaScript to dynamically determine how records in a list view are displayed. This JavaScript runs upon page load, so it can handle current time-dependent values much better than a calculated column.

要使用客户端呈现,请创建一个JavaScript文件来控制视图的显示方式.您可以将该文件上载到SharePoint上的某个地方,人们将至少对该文件具有读取"访问权限,然后编辑要以其他方式显示的列表视图Web部件,然后将其设置为"JSLink".属性以指向您的JavaScript文件.

To use client-side rendering, you create a JavaScript file that controls how the view displays. You upload that file to somewhere on SharePoint where people will have at least Read access to it, then edit the list view web part that you want to display differently and set its "JSLink" property to point to your JavaScript file.

查看 此答案 ,以获取使用JSLink文件进行欺骗的示例动态日期字段.

Check out this answer for an example of using a JSLink file to spoof a dynamic date field.

Microsoft还提供了一些文档此处,但我认为他们所做的工作超出了必要(在示例中,在Visual Studio中创建了一个完整的新列表定义项目,而不仅仅是为现有列表创建JSLink JavaScript文件).

Microsoft also provides some documentation here but I think they do more work than is necessary (creating an entire new list definition project in Visual Studio for their example instead of just creating a JSLink JavaScript file for an existing list).

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

A few other options are mentioned in the older question linked above:

  1. 条件格式:您可以应用条件格式来突出显示符合特定条件的记录.可以使用SharePoint Designer或HTML/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.

过滤后的列表视图:由于列表视图是实时查询和生成的,因此您可以在列表视图过滤器中使用易失值.您可以设置一个列表视图Web部件,仅显示Created等于[Today]的项目.由于您可以在一个页面上放置多个列表视图Web部件,因此您可以在一个部分中放置今天的项目,而在另一个Web部件中放置所有其他项目,从而在视觉上实现分隔.

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.

工作流程,计时器作业或计划任务:您可以使用重复过程每天设置正常(非计算)列的值.您需要谨慎使用此方法,以确保良好的性能.例如,如果列表超过列表视图阈值,则不希望它查询和更新列表中的每个项目.

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天之内到期的所有项目.您还可以对视图进行排序,以显示到期日更早,更接近顶部的项目.

To expand on the Filtered List Views option, you can have a view that shows only items that are due within a certain number of days. For example, you can display all the items due within 7 days by filtering where the Due Date field is less than [Today]+7 and Due Date is greater than or equal to [Today]. You could also sort the view to show the items with earlier due dates closer to the top.

这篇关于SharePoint 2013/2016计算列停止计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆