hi,
i am getting Error:unable to get property 'getValue' of undefined or null reference in javascript
while i am writing a snippet to retrieve contactid from lookup.
here is my snippet:
function contactField_Onchange()
{
var jobTitle = Xrm.Page.data.entity.attributes.get("new_title");
var fullName = Xrm.Page.data.entity.attributes.get("new_fullname");
var emailAddress = Xrm.Page.data.entity.attributes.get("new_email");
var mobilePhone = Xrm.Page.data.entity.attributes.get("new_mobile");
var contactjobTitle = "";
var contactName = "";
var contactEmail = "";
var contactMobile = "";
///contact
//Get parentcustomerid lookup value
var lookupItem = new Array();
lookupItem = Xrm.Page.getAttribute("contactid").getValue(); //getting error here..
if (lookupItem != null)
{
var guid = lookupItem[0].id;
var parentcustomeridValue = guid;
var entType = lookupItem[0].entityType;
var parentcustomertypeValue = entType;
if (parentcustomeridValue != null && parentcustomertypeValue == "contact")
{
//get entity contact
var entity = "Contact";
var fields = "*";
var filter = "ContactId eq guid'" + parentcustomeridValue + "'";
var ret = retrieveMultipleSync(entity, filter, fields);
if (ret != null)
{
if (ret[0].jobtitle != null)
{
contactjobTitle = ret[0].jobtitle;
jobTitle.setValue(contactjobTitle);
}
if(ret[0].fullname != null)
{
contactName = ret[0].fullname;
fullName.setValue(contactName);
}
if(ret[0].emailaddress1 != null)
{
contactEmail = ret[0].emailaddress1;
emailAddress.setValue(contactEmail);
}
if(ret[0].mobilephone != null)
{
contactMobile = ret[0].mobilephone;
mobilePhone.setValue(contactMobile);
}
}
}
}
else
{
jobTitle.setValue(contactjobTitle);
fullName.setValue(contactName);
emailAddress.setValue(contactEmail);
mobilePhone.setValue(contactMobile);
}
}
can anyone help me to resolve this issue.
Thank You
Habeeb.
*This post is locked for comments
I have the same question (0)