Hi,
I have problem when I try to setValue lookup field, it's throw Unable to get property 'trim' of undefined or null reference. the value that I enter is not null( I checked).
it's happen only in contact (account is ok).
I don't know what is the problem :/
my code:
function getAccountLookup()
{
try {
var xrmObject = Xrm.Page.context.getQueryStringParameters();
if (xrmObject != null&& xrmObject["account_id"]) {
//account
var id = xrmObject["account_id"].toString();
var name = xrmObject["account_name"].toString();
var entityType = xrmObject["account_type"].toString();
SetLookupValue("customerid", name, id, entityType);
//contact
if (xrmObject["contact_id"] && xrmObject["contact_id"] != null) {
var id = xrmObject["contact_id"].toString();
var name = xrmObject["contact_name"].toString();
var entityType = xrmObject["contact_type"].toString();
SetLookupValue("fl_contactid", name, id, entityType);
}
}
catch (e)
{ }
}
function SetLookupValue(lookup, name, id, entityType)
{
if (Xrm.Page.getAttribute(lookup) != null) {
var lookupValue = new Array();
lookupValue[0] = new Object();
lookupValue[0].id = id;
lookupValue[0].name = name;
lookupValue[0].entityType = entityType;
Xrm.Page.getAttribute(lookup).setValue(lookupValue);
}
}
hope you can help me :)