2016-09-30 33 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); 
    } 
} 
相關問題