Monday, July 23, 2012

Get LookUp Text into Text Field :

function GetLookupDetails()

{

     var lookupItem = new Array();



     //This is Field Name and should be in Small letters

 //Here new_contact is Lookup Field Name
     lookupItem = Xrm.Page.getAttribute("new_contact").getValue();



     if(lookupItem != null)

     {

           var name = lookupItem[0].name;

           //This is to Get GUID which is ContactId in SQL Table, Use this to Query remaining details.

           var guid = lookupItem[0].id;

           var entType = lookupItem[0].entityType;



           alert(name);

           alert(guid);

           alert(entType);



                   //This is to Set Values to Textbox, Remember not for Lookup fields.

           Xrm.Page.getAttribute("new_mainphone").setValue(guid);

           Xrm.Page.getAttribute("new_homephone").setValue(guid);





     }

}

No comments: