Asked by:
Javascript error after upgrading to CRM 2016 On premise - unable to get property 'trim' of undefined or null reference

Question
-
We have upgraded CRM to the 2016 on premise version and installed the patch 0.1
We are getting a javascript error (which doesn't happen in CRM 2015):
- unable to get property 'trim' of undefined or null reference
We get this when trying to set the primarycontactid on Incident using the javascript below
Has anyone come across this issue when using CRM 2016?
JavaScript code to set the lookup value:
var attributename="primarycontactid";
var type="contact";
var id= "a068ad24-f439-477a-9a29-4e362cf6a0ce";
var name="test contact";
function SetSimpleLookupValue(attributename, type, id, name)
{
try
{
var lookupReference = [];
lookupReference[0] = {};
lookupReference[0].id = id;
lookupReference[0].entityType = type;
lookupReference[0].name = name;var lookupObject = Xrm.Page.getAttribute(attributename);
if (lookupObject !== null)
{
lookupObject.setValue(lookupReference);
} else
{
alert('Lookup field could not be found');
}
}
catch(err)
{
var a = err.message;
}
}
- Edited by Tims123456 Friday, April 29, 2016 11:04 AM
Friday, April 29, 2016 11:02 AM
All replies
-
Hello,
What line in that code gives a problem with "trim"?
Regards
Rickard Norström Developer CRM-Konsulterna
http://www.crmkonsulterna.se
Swedish Dynamics CRM Forum: http://www.crmforum.se
My Blog: http://rickardnorstrom.blogspot.seFriday, April 29, 2016 1:31 PM -
Its when we call this line:
lookupObject.setValue(lookupReference);
Tuesday, May 3, 2016 7:45 AM -
Is there any difference if you change your code to
var lookup = new Array();
lookup[0] = new Object();
lookup[0].id = id;
lookup[0].name = name;
lookup[0].entityType = type;
Xrm.Page.getAttribute("attributename").setValue(lookup);Regards
Rickard Norström Developer CRM-Konsulterna
http://www.crmkonsulterna.se
Swedish Dynamics CRM Forum: http://www.crmforum.se
My Blog: http://rickardnorstrom.blogspot.seTuesday, May 3, 2016 7:54 AM -
Hi
There isn't a change with that code, its still raising the javascript error about not been able to get the property trim?
(I thought the error had stopped after upgrading documents core pack, but the error is still happening after more testing)
Thanks
- Marked as answer by Tims123456 Tuesday, May 3, 2016 11:49 AM
- Unmarked as answer by Tims123456 Wednesday, May 4, 2016 8:26 AM
- Edited by Tims123456 Wednesday, May 4, 2016 9:05 AM
Tuesday, May 3, 2016 11:49 AM -
Its a bug in CRM 2016. Refer to the following thread
https://community.dynamics.com/crm/f/117/p/190275/482107Tuesday, November 15, 2016 5:13 PM -
Hi all,
This issue is not repro for us in CRM 2016 Update 1. However, in CRM 2016 we are facing this issue.
Following blog post has a fix for this issue.
http://a-crm.blogspot.com/2016/03/crm-2016-update-lookup-field-bug.html
Hope it helps.
Vikranth Pandiri Blog: http://howto-mscrm.blogspot.com Twitter: @TweetVikranth "Please Mark it as answer if it helps in resolving your query"
- Proposed as answer by Vikranth Pandiri Saturday, November 19, 2016 12:25 AM
Saturday, November 19, 2016 12:24 AM