Hi guys!
I need to get the actual value of a field at the moment of typing any value on it. I need a function that should be fire at the moment when the value is changed. I don't mean get the value when the form is saved. I need to get the value of the field "online".
There is any way to do that?
Update:
I have added the following code to my onLoad event
// A namespace defined for the sample code
// As a best practice, you should always define
// a unique namespace for your libraries
var Sdk = window.Sdk || {};
(function ()
{
// Code to run in the form OnLoad event
this.formOnLoad = function (executionContext)
{
var formContext = executionContext.getFormContext();
var name = formContext.getAttribute("name").getValue();
var d = window.parent.document.getElementById("name");
d.oninput = function () { suggest("party", name d.oninput.arguments[0].data); };
}
function suggest(resource, query)
{
var API_KEY = "test";
var xhr = new XMLHttpRequest();
var serviceUrl = "Url" resource;
xhr.open("POST", serviceUrl, true);
xhr.setRequestHeader("Authorization", "Token " API_KEY);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
var json = JSON.parse(xhr.responseText);
console.log(json);
}
};
var data = "{ \"query\": \"" query "\" }";
xhr.send(data);
}
}).call(Sdk);
I now that this code is unsopported but i can't find a correct solution. With my code i can't get the value of the last input keyword but i cant get the text value that i already typed. Any idea?
I'm using CRM 365 v.9 On premise