簡體   English   中英

使用Xrm.Navigation.openWebResource()后如何從Web資源取回表單數據

[英]How to get back form data from Web resource after using Xrm.Navigation.openWebResource()

我有一個單擊按鈕打開的 Web 資源,如下所示:

var windowOptions = { height: 400, width: 50 };
Xrm.Navigation.openWebResource("DCWIMS_/html/datepicker.html", windowOptions);

我在 html webresource 中有一個小輸入字段(你可以猜到,它是一個日期時間字段)。 我的問題是,如何在表單關閉后獲取字段數據? 我從一個函數中調用了上面的代碼

 function Cancel() { var contract_id = Xrm.Page.data.entity.getId(); var contract_guid = contract_id.replace(/[{}]/g, ""); var windowOptions = { height: 400, width: 50 }; Xrm.Navigation.openWebResource("DCWIMS_/html/datepicker.html", windowOptions); //need field data to be returned so I can set a field in the form to its value var datefield = ?? formContext.getAttribute("new_cancellationdate").setValue(datefield); //Set the stage to send enquiry letter XrmSvcToolkit.setState({ id: Xrm.Page.data.entity.getId(), entityName: "new_contract", stateCode: 1, statusCode: 100000002, //Cancelled async: false }); }

這是 html 網絡資源:

 <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="ClientGlobalContext.js.aspx" type="text/javascript"></script> <title>Set Cancellation Date</title> <script> window.onload = function () { document.getElementById('party-time').onsubmit = function () { var date = document.getElementById('party-time').value; webResourceData.windowCallback(date); // You must return false to prevent the default form behavior return false; }; }; function Quit() { window.close(); } </script> </head> <body> <fieldset> <legend>Cancellation Date</legend> <div> <label for="party-time">Date/time:</label> <input type="datetime-local" id="party-time" name="party-time" value="" min="" max="" /> <button type="submit" onclick="Quit()">Submit </button> </div> </fieldset> </body> </html>

嘗試這個。 不是從 webresource 返回值到父窗口,而是從 HTML 本身分配它。

    function Quit() {
            window.opener.Xrm.Page.getAttribute("new_cancellationdate").setValue(document.getElementById('party-time').value);

            window.close();
    }

暫無
暫無

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

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