Set lookup in JavaScript possible?

M

m1sterd

Guest
Hi,

I wonder if it is possible to set a lookup using javascript. According the
sdk, I should set the id, the name and the typename which I do. However,
nothing is displayed. Is it possible or is only possible from server side?
 


Hi,
Yes, it is possible and it is exactly like how it is mentioned in CRM SDK.

//Create an array to set as the DataValue for the lookup control.
var lookupData = new Array();
//Create an Object add to the array.
var lookupItem= new Object();
//Set the id, typename, and name properties to the object.
lookupItem.id = '{1AAC1363-01A1-DB11-8432-0003FF9CE217}';
lookupItem.typename = 'account';
lookupItem.name = 'A Bike Store';
// Add the object to the array.
lookupData[0] = lookupItem;
// Set the value of the lookup field to the value of the array.
crmForm.all.parentaccountid.DataValue = lookupData;

--
PLEASE do click on Yes or No button if this post is helpful or not for our
feedback.

uMar Khan :: Freelance Consultant
My Email :: imumar at gmail dot com
My Blog :: http://umarkhan.wordpress.com


"m1sterd" wrote:

> Hi,
>
> I wonder if it is possible to set a lookup using javascript. According the
> sdk, I should set the id, the name and the typename which I do. However,
> nothing is displayed. Is it possible or is only possible from server side?

 
Thanks!

"uMar Khan :: CRM Freelance Consultant" wrote:

> Hi,
> Yes, it is possible and it is exactly like how it is mentioned in CRM SDK.
>
> //Create an array to set as the DataValue for the lookup control.
> var lookupData = new Array();
> //Create an Object add to the array.
> var lookupItem= new Object();
> //Set the id, typename, and name properties to the object.
> lookupItem.id = '{1AAC1363-01A1-DB11-8432-0003FF9CE217}';
> lookupItem.typename = 'account';
> lookupItem.name = 'A Bike Store';
> // Add the object to the array.
> lookupData[0] = lookupItem;
> // Set the value of the lookup field to the value of the array.
> crmForm.all.parentaccountid.DataValue = lookupData;
>
> --
> PLEASE do click on Yes or No button if this post is helpful or not for our
> feedback.
>
> uMar Khan :: Freelance Consultant
> My Email :: imumar at gmail dot com
> My Blog :: http://umarkhan.wordpress.com
>
>
> "m1sterd" wrote:
>
> > Hi,
> >
> > I wonder if it is possible to set a lookup using javascript. According the
> > sdk, I should set the id, the name and the typename which I do. However,
> > nothing is displayed. Is it possible or is only possible from server side?

 

Back
Top