簡體   English   中英

在 onchange 事件的 MS CRM 日期時間字段中設置特定日期和年份

[英]Set a specific date and year in a MS CRM date time field in the onchange event

我有兩個日期時間字段。 在第一個字段中,如果設置了日期,則在第二個日期時間字段中,日期應自動使用此格式填充。

例如

開始日期: 1: 09/30/2016

結束日期 2 : 09/29/2017。

以下是我的代碼:

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);
}}

我已經設置了年份但無法設置日期。 所以請幫助我提出您的建議。

嘗試以下代碼:

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);
   }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM