How to get data from HTML web resource components to CRM 2016 form.
Hello CRM Developers,
Here is my new post, In this post I am going to tell how we can get data from html web resource to crm 2016 form events.
On CRM 2016 from if there is a html web resource placed in iframe and suppose you have text boxes and check boxes on html page and you want data from text boxes and check boxes on crm form events like on save or on field change events, we can get this data by using below java script code.
Below is a sample code in it we are reading data from check boxes on html page and after reading we can save that data on save event of crm 2016 form.
On CRM 2016 from if there is a html web resource placed in iframe and suppose you have text boxes and check boxes on html page and you want data from text boxes and check boxes on crm form events like on save or on field change events, we can get this data by using below java script code.
Below is a sample code in it we are reading data from check boxes on html page and after reading we can save that data on save event of crm 2016 form.
function readDataFromHTMLPage() {
//Get web resource control
var webResCrtl = Xrm.Page.ui.controls.get("WebResource_TestWebPage");
if (webResCrtl) {
//get web resource object
var webResObject = webResCrtl.getObject();
if (webResObject) {
//Get HTML document
var htmlDocument = webResObject.contentWindow.document;
if (htmlDocument) {
//Get all check boxes with class name "items"
var checkBoxes = htmlDocument.getElementsByClassName("items")
var selectedIntractionCheckBoxes = "";
for (var i = 0; i < checkBoxes.length; i++) {
//Get Selected check boxes
if (checkBoxes[i].childNodes['0'].checked == true) {
if (selectedIntractionCheckBoxes == "")
//write your logic to perform action
selectedIntractionCheckBoxes = checkBoxes[i].textContent;
}
}
}
}
}
}
For further help you can leave a comment.
Enjoy the great technology Dynamics CRM. Good Luck .....!!!! Please feel free to leave comment.
Thanks