2016-09-30 84 views
-1

我有两个日期时间字段。 在第一个字段中,如果设置了日期,则在第二个日期时间字段中,日期应该以此格式自动填充 。在onchange事件中的MS CRM日期时间字段中设置特定的日期和年份

例如

开始时间:1:2016年9月30日

结束日期2:2017年9月29日。

以下是我的代码:

function SetOneplusyearminus1date() { 
debugger; 
var start = Xrm.Page.getAttribute("msdyn_startdate").getValue(); 
if (start != null) 
{ 
    var endYear = start.setYear(start.getFullYear() + 1); 
    Xrm.Page.getAttribute("msdyn_enddate").setValue(endYear); 
}} 

我已经设置了一年,但无法设定日期。 所以,请帮助我的建议。

回答

0

尝试下面的代码:

function SetOneplusyearminus1date() { 
    debugger; 
    var start = Xrm.Page.getAttribute("msdyn_startdate").getValue(); 
    if (start != null) { 
     start.setDate(start.getDate() - 1); 
     start.setYear(start.getFullYear() + 1); 
     Xrm.Page.getAttribute("msdyn_enddate").setValue(start); 
    } 
} 
相关问题