- OnSave function - Lookup values being truncated in Contacts
- Posted by Matt on March 3rd, 2006
Hi all,
I am currently returning a value from the Parent Customer ID field in
Contacts using OnSave . These values are being passed into a Web Service and
onto another database.
Code below:
var lookupItem = new Array;
lookupItem = crmForm.all.parentcustomerid.DataValue;
if (lookupItem[0] != null)
{
var sAccountID = lookupItem[0].name;
}
The Problem I am getting is when I return a value from the lookup like "A &
E Builder", the string is truncated and I am left with 'A'.
Does anyone no a workaround for this? I really need to return the full text
value as it appears in CRM.
I suspect I need to change the "lookupItem[0].name" to something like
lookupItem[0].name.selectedText...?
Cheers
Matt
- Posted by Matt Parks on March 3rd, 2006
Guessing it has to do with the "&" in the value. Are you certain you aren't
getting the full value and whatever method you are using to display it isn't
truncating it? The "&" is a special char in HTML, so if you are putting it
on a page, it could be reneded as non-visible.
--
Matt Parks
MVP - Microsoft CRM
"Matt" <Matt@discussions.microsoft.com> wrote in message
news:A7E06C1C-3EFB-4E04-911F-D1E38678BCF8@microsoft.com...
Hi all,
I am currently returning a value from the Parent Customer ID field in
Contacts using OnSave . These values are being passed into a Web Service and
onto another database.
Code below:
var lookupItem = new Array;
lookupItem = crmForm.all.parentcustomerid.DataValue;
if (lookupItem[0] != null)
{
var sAccountID = lookupItem[0].name;
}
The Problem I am getting is when I return a value from the lookup like "A &
E Builder", the string is truncated and I am left with 'A'.
Does anyone no a workaround for this? I really need to return the full text
value as it appears in CRM.
I suspect I need to change the "lookupItem[0].name" to something like
lookupItem[0].name.selectedText...?
Cheers
Matt
- Posted by Matt on March 5th, 2006
Hi Matt
I agree, it is definitly the "&" value.
The way I found out the returned value was using SQL profiler to watch it
being passed into my Stored Proc. I am not displaying it on a web page, just
collecting it from CRM and passing it via a URI string into a vb.NET web
service (and onto an external database). The Web Service is simply passing
the values, there is no data manipulation occuring at that point.
I am reasonbly certain the truncating is taking place within the javascript
var sAccountID = lookupItem[0].name
I will do some further tests anyway see what more I can find. Any further
help would be appreciated.
Thanks for your help, Cheers
"Matt Parks" wrote
- Posted by Matt Parks on March 9th, 2006
The problem you have is you need to encode the value before submitting it
via the URI. This is a special character and is causing the problem.
--
Matt Parks
MVP - Microsoft CRM
"Matt" <Matt@discussions.microsoft.com> wrote in message
news:1C04F437-AAB1-4E20-B397-A704EB9B92B0@microsoft.com...
Hi Matt
I agree, it is definitly the "&" value.
The way I found out the returned value was using SQL profiler to watch it
being passed into my Stored Proc. I am not displaying it on a web page, just
collecting it from CRM and passing it via a URI string into a vb.NET web
service (and onto an external database). The Web Service is simply passing
the values, there is no data manipulation occuring at that point.
I am reasonbly certain the truncating is taking place within the javascript
var sAccountID = lookupItem[0].name
I will do some further tests anyway see what more I can find. Any further
help would be appreciated.
Thanks for your help, Cheers
"Matt Parks" wrote
- Posted by Matt on March 13th, 2006
Gotcha, Thanks very much Matt.
I have read about the encoding and will add this to my Javascript.
Thanks again
Cheers
Matt
"Matt Parks" wrote: