微软动态CRM专家罗勇 ,回复338或者20190521可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me.
计算字段是从Dynamics CRM 2015 SP1版本开始推出的一个好东西,详情可以参考官方文档 Define calculated fields to automate manual calculations ,我以前的博文也有介绍。
我发现,我定义了如下的计算字段 (calculated field):
定义的计算公示如下:
后来我发现这个实体在使用Ribbon Workbench定义按钮后,发布包括这个字段定义的实体时候会报错,导出来以后,导入到别的环境也会报错(Error while importing Calculated fields name new_dayssinceinvoice)。
报错信息是:You can't use Now(), which is of type DateTime, with the current function.
根据官方的提示:All DIFF functions require that the first Date and Time field and the second Date and Time field have the same behavior: User Local, Date Only or Time-Zone Independent. If the behavior of the second field doesn’t match the behavior of the first field, the error message is shown, indicating that the second field can’t be used in the current function. More information: Behavior and format of the Date and Time field.
我才应该是Now的行为(behavior) 是 User Local的,而我定义的计算公示中涉及到的另一个字段是 Time-Zone Independent导致的。于是我将涉及到的那个字段的Behavior改成 User Local后问题解决。当然拉,不能在界面上直接改成User Local,需要删除该字段后重建。