0

我在 CRM 2013 中工作,我需要设置我的文本框的日期并将其保存到 CRM 2013 数据库。

看看我的代码:

var CRMForm = document.parentWindow.parent.Xrm.Page;

var currentDateTime = new Date();

CRMForm.getAttribute("date").setValue(currentDateTime);

但我在这里遇到一个例外:堆栈空间不足

4

2 回答 2

0

我自己得到了解决方案,如下所示:

var dt= CRMForm.getAttribute("date");

if(dt.getValue() != null)

{

dt.setValue(dt.getValue().setFullYear(currentDateTime.getFullYear()));

dt.setValue(dt.getValue().setDate(currentDateTime.getDate()));

dt.setValue(dt.getValue().setMonth(currentDateTime.getMonth()));

}
于 2014-09-29T09:26:21.740 回答
0

您正在处理表单还是自定义 Web 资源?

我很困惑,因为您正在获取父表单,

var currentDateTime = new Date();
Xrm.Page.getAttribute("requestdeliveryby").setValue(currentDateTime);

这应该绰绰有余。请记住,您需要在编辑表单时正确注册它:

属性->事件->OnLoad ? 查看您的示例看起来您正试图从错误的表单中获取 Xrm 命名空间。

于 2014-09-25T01:24:09.100 回答