Hi,
I am novice in js-scripting and try to retrieve fields from a related entitity "contact"
and fill some fields with contact-details.
This should happen onchange of a lookup-field "new_projektkontakt"
I have loaded the SDK.WEBAPI.js library befor my script :
function retrieveContact() {
var contact = Xrm.Page.getAttribute('new_projektkontakt').getValue();
SDK.REST.retrieveRecord("", "Contact", "EMailAddress1,FullName,MobilePhone,Telephone1", null, function(result) {
var eMailAddress1 = result.EMailAddress1;
var fullName = result.FullName;
var mobilePhone = result.MobilePhone;
var telephone1 = result.Telephone1;
}, function(error) {
Xrm.Utility.alertDialog(error.message);
});
Xrm.Page.getAttribute('new_name').setValue(fullname);
Xrm.Page.getAttribute('new_email').setValue(eMailAddress1);
Xrm.Page.getAttribute('new_mobiltelefon').setValue(mobilePhone);
Xrm.Page.getAttribute('new_festnetz').setValue(telephone1);
}
I get the errormessage :
ReferenceError: retrieveContact is not defined
at eval (eval at RunHandlerInternal (xxxxxxxgmbh.crm4.dynamics.com/.../ClientApiWrapper.aspx), <anonymous>:1:1)
at RunHandlerInternal (xxxxxxxgmbh.crm4.dynamics.com/.../ClientApiWrapper.aspx)
at RunHandlers (xxxxxxxgmbh.crm4.dynamics.com/.../ClientApiWrapper.aspx)
at ExecuteHandler (xxxxxxxgmbh.crm4.dynamics.com/.../ClientApiWrapper.aspx)
at Mscrm.TurboForm.Control.CustomScriptsManager.$Db_1 (xxxxxxxgmbh.crm4.dynamics.com/.../formcontrols.js)
at Mscrm.TurboForm.Control.CustomScriptsManager.executeHandler (xxxxxxxgmbh.crm4.dynamics.com/.../formcontrols.js)
at Mscrm.TurboForm.Control.CustomScriptsManager.executeHandlerByDescriptor (xxxxxxxgmbh.crm4.dynamics.com/.../formcontrols.js)
at xxxxxxxgmbh.crm4.dynamics.com/.../formcontrols.js
at xxxxxxxgmbh.crm4.dynamics.com/.../global.ashx
at Mscrm.TurboForm.Control.Data.LookupDataAttribute.fireOnChange (xxxxxxxgmbh.crm4.dynamics.com/.../formcontrols.js)
Help is much appreciated !!
Harald
*This post is locked for comments