Hi, I am writing a basic jscript for CRM 2013.
When I try to check if my js works, it gave me the next error:
unable to get property 'set value' of undefined or null reference CRM.
I was trying to figure out what is the mistake I made but I can´t realize.
This is my js code:
function mailOnchange()
{
var lookup = Xrm.Page.data.entity.attributes.get("tps_email").getValue();
if (lookup === null) {
return false;
}
if (lookup[0].id == null) {
return false;
}
var columns = ["subject", "description", "from"];
var retrievedEmail = XrmServiceToolkit.Soap.Retrieve("email", lookup[0].id, columns);
//Seteo el valor del titulo de la busqueda
var name = Xrm.Page.data.entity.attributes.get("tps_titulo");
name.setValue(retrievedEmail.attributes.subject.value);
//Cargo el mensaje del mail
var descripcion = Xrm.Page.data.entity.attributes.get("tps_descripciondepuesto");
descripcion.setValue(retrievedEmail.attributes.description.value);
setIframe(retrievedEmail.attributes.description.value);
//Seteo al referente de la busqueda (el que me mando el mail)
var referente = Xrm.Page.data.entity.attributes.get("tps_referente");
var contact = retrievedEmail.attributes.from.value[0];
var lookupValue = new Array();
lookupValue[0] = new Object();
lookupValue[0].id = contact.id;
lookupValue[0].name = contact.name;
lookupValue[0].entityType = "contact";
referente.setValue(lookupValue);
UpdateAccount(contact);
return true;
}
Thanks!