2016-09-30 9 views
-1

2つの日付時刻フィールドがあります。 最初のフィールドでは、日付が設定されている場合、2番目の日付時刻フィールドには、この形式の日付が自動的に入力されます( )。たとえばについては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); 
    } 
} 
関連する問題