简体   繁体   English

使用Xrm.Navigation.openWebResource()后如何从Web资源取回表单数据

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

I have a Web resource that is opened on the click of a button as follows:我有一个单击按钮打开的 Web 资源,如下所示:

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

I have a little input field inside the html webresource (as you can guess, it's a date time field).我在 html webresource 中有一个小输入字段(你可以猜到,它是一个日期时间字段)。 My question is, how can I get the field data after the form is closed?我的问题是,如何在表单关闭后获取字段数据? I called the code above from a function我从一个函数中调用了上面的代码

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

Here is the html webresource:这是 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>

Try this.尝试这个。 Instead of returning value from webresource to parent window, assign it from HTML itself.不是从 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.

相关问题 无法从CRM 2011中的HTML Web资源中访问Xrm.Page.data - Cannot access Xrm.Page.data from within HTML web resource in CRM 2011 在新窗口中打开的 Web 资源中使用 Xrm.WebApi 方法 - Using Xrm.WebApi method in Web Resource opened in a new window Xrm.Utility.openwebresource打开新选项卡 - Xrm.Utility.openwebresource opens new tab 无法从打开的框架网络资源Dynamics CRM 2011中访问window.parent的Xrm.data.entity对象 - Unable to access window.parent's Xrm.data.entity object from a opened frame web resource Dynamics CRM 2011 无法从CRM中的HTML Web资源中访问Xrm.Page.context - Cannot access Xrm.Page.context from within HTML web resource in CRM CRM Dynamics,如何使用一种形式传递值,并使用Xrm.Utility.openEntityForm()在新的Entity(form)中设置值; - CRM Dynamics , How to pass values from one form and set the values in a new Entity(form) using Xrm.Utility.openEntityForm(); Xrm.Navigation.openForm 从上一个表单自动设置查找字段 - Xrm.Navigation.openForm set lookup field automatically from the previous form 将数据从对象取回表单 - Get data back from object into form 独立 Web 资源中的 Powerapps Xrm.WebApi - Powerapps Xrm.WebApi in a stand alone Web Resource 如何从Microsoft Dynamics CRM表单到html Web资源获取价值 - how to get value from microsoft dynamics crm form to html web resource
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM