Hi masters,
I have this question because i'm beign working with javascript and Dynamics CRM 2016 or the Dynamics 365 upgrade... i know it comes with some changes, but i'll go to the point...
I have data in a text field on accounts and need that data on the incidents form and on quick creation form for incidents, so i work with javascript so this is my script.
/**********************************.1.*****************************************/
function update_E_C_OnChange(){
if(Xrm.Page.getAttribute("customerid").getValue()!=null && Xrm.Page.getAttribute("customerid").getValue()!="undefined"){
var orgURL = "https://" + location.host +"/xrmservices/2011/OrganizationData.svc/";
var odataSelect = "AccountSet?$select=satc_EstadoContratoHide&$filter=AccountId eq guid'" + Xrm.Page.getAttribute("customerid").getValue()[0].id + "'";
if (typeof console != "undefined") {
console.log(orgURL + odataSelect);
}
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: orgURL + odataSelect,
beforeSend: function(XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
success: function(data, textStatus, XmlHttpRequest) {
if(data.d.results.length > 0){
var customer = data.d.results[0];
Xrm.Page.getAttribute("satc_estadocontrato").setValue(customer.satc_EstadoContratoHide);
}
},
error: function(XmlHttpRequest, textStatus, errorThrown) {
if (typeof console != "undefined") {
console.log("ERROR: " + odataSelect + " - " + errorThrown);
}
}
});
}
}
The field it's called "satc_estadocontratohide" and need to set his data on my field "satc_estadocontrato", i' getting an error tells me hey dude that function is not registered...
Update:
Basically i forgot to load jQuery before the script... Resolved :D xD